/**
 * 保存第一步结果信息
 * */

#ifndef TRAINDIVIDEENGINE_H
#define TRAINDIVIDEENGINE_H

#include "AppCommon.h"
#include "EngineBase.h"
#include "EngineFactory.h"
#include "json/json.h"

class ContainerDivideEngine : public ai_matrix::EngineBase
{
public:
    ContainerDivideEngine();
    ~ContainerDivideEngine();

    APP_ERROR Init() override;
    APP_ERROR DeInit() override;
    APP_ERROR Process() override;

private:
    void initParam();
    void divideInfo(std::shared_ptr<VStep2OutputData> pVStep2OutputData);
    void divideByPixelInfo(std::shared_ptr<VStep2OutputData> pVStep2OutputData);
    void divideByCornerInfo(std::shared_ptr<VStep2OutputData> pVStep2OutputData);
    bool setectBestByCorner();
    void sendBestData(const VSelectBestData& selectBestData);
    void makeResult(const std::shared_ptr<VStep2OutputData>& pVStep2OutputData,
                                VSelectBestData & selectBestData) const;

    std::string strPort0_;
    std::string strPort1_;

    ai_matrix::BaseConfig baseConfig_;
    ai_matrix::IdentifyConfig identifyConfig_;
    ai_matrix::DataSourceConfig dataSourceConfig_;
    std::vector<ai_matrix::DataSourceConfig> vecDataSourceConfig_;

    std::shared_ptr<VStep2OutputData> pVStep2OutputDataPre_ = nullptr;

    std::map<uint32_t, float> mapContainerCenterInfo_;

    int iContainerIndex = 0;

    // 临时存储的正确结果
    std::string stdContainerResult_;

    // 存储识别到的不满足校验规则的箱号数据
    std::vector<VSelectBestData> vecContainerFail_;
    // 存储识别到的满足校验规则的箱号数据
    std::vector<VSelectBestData> vecContainer_;

    bool bLastIsEnd = true;
};

ENGINE_REGIST(ContainerDivideEngine)

#endif
