|
@@ -11,7 +11,7 @@ void InferNode::work()
|
|
printf("InferNode %s\n", name_.c_str());
|
|
printf("InferNode %s\n", name_.c_str());
|
|
while (running_)
|
|
while (running_)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ bool has_data = false;
|
|
for (auto& input_buffer : input_buffers_)
|
|
for (auto& input_buffer : input_buffers_)
|
|
{
|
|
{
|
|
std::shared_ptr<meta::MetaData> metaData;
|
|
std::shared_ptr<meta::MetaData> metaData;
|
|
@@ -19,20 +19,18 @@ void InferNode::work()
|
|
{
|
|
{
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+ has_data = true;
|
|
// printf("Node %s get data from %s\n", name_.c_str(), input_buffer.first.c_str());
|
|
// printf("Node %s get data from %s\n", name_.c_str(), input_buffer.first.c_str());
|
|
- // do something
|
|
|
|
cv::Mat image = metaData->image;
|
|
cv::Mat image = metaData->image;
|
|
int width = image.cols;
|
|
int width = image.cols;
|
|
int height = image.rows;
|
|
int height = image.rows;
|
|
|
|
|
|
- // // cv::imwrite("test.jpg", image);
|
|
|
|
- // int x = rand() % width;
|
|
|
|
- // int y = rand() % height;
|
|
|
|
- // int w = rand() % (width - x);
|
|
|
|
- // int h = rand() % (height - y);
|
|
|
|
- // metaData->boxes.push_back(data::Box(x, y, x + w, y + h, 0.9, 0));
|
|
|
|
-
|
|
|
|
// auto res = model_->forward(tensor::cvimg(image), image.cols, image.rows, 0.0f, 0.0f);
|
|
// auto res = model_->forward(tensor::cvimg(image), image.cols, image.rows, 0.0f, 0.0f);
|
|
|
|
+ if (!model_)
|
|
|
|
+ {
|
|
|
|
+ printf("model is nullptr\n");
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
auto res = model_->forward(tensor::cvimg(image));
|
|
auto res = model_->forward(tensor::cvimg(image));
|
|
for (auto& r : res)
|
|
for (auto& r : res)
|
|
{
|
|
{
|
|
@@ -45,6 +43,13 @@ void InferNode::work()
|
|
output_buffer.second->push(metaData);
|
|
output_buffer.second->push(metaData);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (!has_data)
|
|
|
|
+ {
|
|
|
|
+ std::unique_lock<std::mutex> lock(mutex_);
|
|
|
|
+ cond_var_->wait_for(lock, std::chrono::milliseconds(100), [this] {
|
|
|
|
+ return !running_; // 等待时检查退出条件
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|