123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #include "nodes/base/base.hpp"
- #include "nodes/infer/inferNode.hpp"
- #include <unordered_map>
- #include <random>
- namespace Node
- {
- void InferNode::work()
- {
- printf("InferNode %s\n", name_.c_str());
- while (running_)
- {
-
- for (auto& input_buffer : input_buffers_)
- {
- std::shared_ptr<meta::MetaData> metaData;
- if (!input_buffer.second->try_pop(metaData))
- {
- continue;
- }
- printf("Node %s get data from %s\n", name_.c_str(), input_buffer.first.c_str());
- // do something
- cv::Mat image = metaData->image;
- int width = image.cols;
- 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, "test"));
- for (auto& output_buffer : output_buffers_)
- {
- printf("Node %s push data to %s\n", name_.c_str(), output_buffer.first.c_str());
- output_buffer.second->push(metaData);
- }
- }
- }
- };
- } // namespace Node
|