|
@@ -3,6 +3,7 @@
|
|
|
#include <iostream> // For std::cerr
|
|
|
#include <thread> // For std::this_thread::sleep_for
|
|
|
#include <chrono> // For std::chrono::milliseconds
|
|
|
+#include <filesystem>
|
|
|
|
|
|
namespace GNode
|
|
|
{
|
|
@@ -46,7 +47,7 @@ bool StreamNode::open_stream() {
|
|
|
PLOGI.printf("StreamNode [%s]: GPU Demuxer and Decoder created successfully.", name_.c_str());
|
|
|
status_ = StreamStatus::OPENED;
|
|
|
}
|
|
|
- else
|
|
|
+ else if (decode_type_ == DecodeType::CPU)
|
|
|
{
|
|
|
cap_ = std::make_shared<cv::VideoCapture>();
|
|
|
if (!cap_->open(stream_url_))
|
|
@@ -66,6 +67,11 @@ bool StreamNode::open_stream() {
|
|
|
PLOGI.printf("StreamNode [%s]: CPU cv::VideoCapture opened successfully.", name_.c_str());
|
|
|
status_ = StreamStatus::OPENED;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ status_ = StreamStatus::OPENED;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
frame_count_ = -1;
|
|
|
return true;
|
|
@@ -109,10 +115,14 @@ void StreamNode::work()
|
|
|
{
|
|
|
process_stream_cpu();
|
|
|
}
|
|
|
- else
|
|
|
+ else if (decode_type_ == DecodeType::GPU)
|
|
|
{
|
|
|
process_stream_gpu();
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ process_stream_foler();
|
|
|
+ }
|
|
|
|
|
|
PLOGI.printf("StreamNode [%s]: Stream processing finished or stopped (Status: %d).",
|
|
|
name_.c_str(), static_cast<int>(status_));
|
|
@@ -135,6 +145,57 @@ void StreamNode::work()
|
|
|
close_stream();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+void StreamNode::process_stream_folder()
|
|
|
+{
|
|
|
+ std::vector<std::string> files;
|
|
|
+ if (!std::filesystem::exists(stream_url_) && !std::filesystem::is_directory(stream_url_))
|
|
|
+ {
|
|
|
+ running_.exchange(false);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ for (const auto& entry : std::filesystem::directory_iterator(stream_url_))
|
|
|
+ {
|
|
|
+ if (entry.is_regular_file())
|
|
|
+ {
|
|
|
+ files.push_back(entry.path().string());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (const auto& file : files)
|
|
|
+ {
|
|
|
+ cv::Mat frame;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ frame = cv::imread(file);
|
|
|
+ }
|
|
|
+ catch (const cv::Exception& ex)
|
|
|
+ {
|
|
|
+ PLOGE.printf("StreamNode [%s] Error: Exception during cv::imread: %s", name_.c_str(), ex.what());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (frame.empty())
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ frame_count_++;
|
|
|
+ if (frame_count_ % skip_frame_ != 0)
|
|
|
+ {
|
|
|
+ continue; // Skip frame
|
|
|
+ }
|
|
|
+
|
|
|
+ auto metaData = std::make_shared<meta::MetaData>();
|
|
|
+ metaData->image = frame.clone();
|
|
|
+ metaData->from = name_;
|
|
|
+ send_output_data(metaData);
|
|
|
+ }
|
|
|
+ PLOGI.printf("StreamNode [%s]: Exiting FOLDER processing loop (Running: %s, Status: %d).",
|
|
|
+ name_.c_str(), running_ ? "true" : "false", static_cast<int>(status_));
|
|
|
+}
|
|
|
+
|
|
|
void StreamNode::process_stream_cpu()
|
|
|
{
|
|
|
if (!cap_ || !cap_->isOpened()) {
|