|
@@ -5,41 +5,56 @@
|
|
|
namespace GNode
|
|
|
{
|
|
|
|
|
|
-void RecordNode::work()
|
|
|
+void RecordNode::handle_data(std::shared_ptr<meta::MetaData>& meta_data)
|
|
|
{
|
|
|
- PLOGI.printf("RecordNode : [%s] start", name_.c_str());
|
|
|
- while (running_)
|
|
|
+ cv::Mat image = meta_data->draw_image;
|
|
|
+ if (!writer_.isOpened())
|
|
|
{
|
|
|
- bool has_data = false;
|
|
|
- for (auto& input_buffer : input_buffers_)
|
|
|
+ writer_.open(record_path_, fourcc_, fps_, cv::Size(image.cols, image.rows));
|
|
|
+ if (!writer_.isOpened())
|
|
|
{
|
|
|
- std::shared_ptr<meta::MetaData> metaData;
|
|
|
- if (!input_buffer.second->try_pop(metaData))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- has_data = true;
|
|
|
- // printf("Node %s get data from %s\n", name_.c_str(), input_buffer.first.c_str());
|
|
|
- cv::Mat image = metaData->draw_image;
|
|
|
- if (!writer_.isOpened())
|
|
|
- {
|
|
|
- writer_.open(record_path_, fourcc_, fps_, cv::Size(image.cols, image.rows));
|
|
|
- if (!writer_.isOpened())
|
|
|
- {
|
|
|
- PLOGE.printf("RecordNode : [%s] cannot open video writer", name_.c_str());
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- writer_ << image;
|
|
|
- }
|
|
|
- if (!has_data) {
|
|
|
- std::unique_lock<std::mutex> lock(mutex_);
|
|
|
- cond_var_->wait_for(lock, std::chrono::milliseconds(100), [this] {
|
|
|
- return !running_; // 等待时检查退出条件
|
|
|
- });
|
|
|
+ PLOGE.printf("RecordNode : [%s] cannot open video writer", name_.c_str());
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
+ writer_ << image;
|
|
|
}
|
|
|
|
|
|
+// void RecordNode::work()
|
|
|
+// {
|
|
|
+// PLOGI.printf("RecordNode : [%s] start", name_.c_str());
|
|
|
+// while (running_)
|
|
|
+// {
|
|
|
+// bool has_data = false;
|
|
|
+// for (auto& input_buffer : input_buffers_)
|
|
|
+// {
|
|
|
+// std::shared_ptr<meta::MetaData> metaData;
|
|
|
+// if (!input_buffer.second->try_pop(metaData))
|
|
|
+// {
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// has_data = true;
|
|
|
+// // printf("Node %s get data from %s\n", name_.c_str(), input_buffer.first.c_str());
|
|
|
+// cv::Mat image = metaData->draw_image;
|
|
|
+// if (!writer_.isOpened())
|
|
|
+// {
|
|
|
+// writer_.open(record_path_, fourcc_, fps_, cv::Size(image.cols, image.rows));
|
|
|
+// if (!writer_.isOpened())
|
|
|
+// {
|
|
|
+// PLOGE.printf("RecordNode : [%s] cannot open video writer", name_.c_str());
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// writer_ << image;
|
|
|
+// }
|
|
|
+// if (!has_data) {
|
|
|
+// std::unique_lock<std::mutex> lock(mutex_);
|
|
|
+// cond_var_->wait_for(lock, std::chrono::milliseconds(100), [this] {
|
|
|
+// return !running_; // 等待时检查退出条件
|
|
|
+// });
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
|
|
|
} // namespace GNode
|