#include "nodes/base/base.hpp"
#include "nodes/analyze/analyzeNode.hpp"


namespace Node
{


void AnalyzeNode::work()
{
    printf("AnalyzeNode %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());
            int width = metaData->image.cols;
            int height = metaData->image.rows;

            auto boxes = metaData->boxes;
            for (auto& box : boxes)
            {
                // 将分析的结果存入到 metaData->result 中
            }
            metaData->result = boxes;
            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