/* * @Author: lishengyin lishengyin@sz-sunwin.com * @Date: 2022-09-04 20:27:57 * @LastEditors: lishengyin * @LastEditTime: 2022-10-25 11:12:35 * @FilePath: /gsd_check/plugins/gsd_InferPlugin.h * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ /** * * gsd_InferPlugin.h * */ #pragma once #include #include #include #include #include #include #include "Util/logger.h" #include "Util/SqlPool.h" #include "InferTools.hpp" #include #include #include #include #include "Base64.h" #include "gsd_CenterGroup.h" #include "uuid.hpp" //using namespace toolkit; namespace gsd { /** * @description: InferTaskType * @param {*} * @return {*} */ enum class InferPluginTaskType{ CHECKT_TASK, CLASSIFY_TASK }; class InferPlugin : public drogon::Plugin { public: InferPlugin() {} /// This method must be called by drogon to initialize and start the plugin. /// It must be implemented by the user. virtual void initAndStart(const Json::Value &config) override; /// This method must be called by drogon to shutdown the plugin. /// It must be implemented by the user. virtual void shutdown() override; /** * @description: StartTask * @return {*} */ virtual void StartTask(); /** * @description: 检查任务 * @param {Mat&} img 图片 * @param {CNStreamInferData&} data 前端的推理数据 * @return {*} */ virtual std::pair CheckTask(std::shared_ptr img, CNStreamInferData::Ptr data = nullptr); /** * @description: 获取结果 * @param {CNStreamInferData&} data1 * @param {CNStreamInferData&} data2 * @return {*} */ virtual std::pair getInfoResult(std::shared_ptr img, CNStreamInferData::Ptr data1, CNStreamInferData::Ptr data2); /** * @description: CreateTask * @return {*} */ virtual std::future> CreateTask(const drogon::HttpRequestPtr& req, InferPluginTaskType type = InferPluginTaskType::CHECKT_TASK); /** * @description: GetBboxCorner * @param {const InferInfo} object * @param {int} img_width * @param {int} img_height * @return {*} */ static std::pair GetBboxCorner(const InferInfo object, int img_width, int img_height); /** * @description: CalcThickness * @param {int} image_width * @param {float} thickness * @return {*} */ static int CalcThickness(int image_width, float thickness); /** * @description: DrawBox * @param {const} cv * @param {const} cv * @param {const} cv * @return {*} */ static void DrawBox(cv::Mat& image, const cv::Point& top_left, const cv::Point& bottom_right, const cv::Scalar color); /** * @description:释放资源 * @return {*} */ virtual void Destroy(); protected: // tools InferTools::Ptr m_InferTools = nullptr; std::shared_ptr pool = nullptr; bool stop_ = false; }; }