123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- /******************************************************************************
- 版权所有 (C), 2019-2029, SDC OS 开源软件小组所有
- ******************************************************************************
- 文 件 名 : yolov3_app.h
- 版 本 号 : 初稿
- 作 者 : athina
- 生成日期 : 2020年7月4日
- 最近修改 :
- 功能描述 : yolov3业务流程
- 函数列表 :
- 修改历史 :
- 1.日 期 : 2020年7月4日
- 作 者 : athina
- 修改内容 : 创建文件
- ******************************************************************************/
- #ifndef __YOLOV3_APP_H__
- #define __YOLOV3_APP_H__
- #include <string>
- #include <memory>
- #include "yuv_queue.h"
- #include "sdc_data_src.h"
- #include "sdc_os_api.h"
- #include "tcpSerEpoll.h"
- #include "Ctimer.h"
- #include "inifile.h"
- #include "dataType/NettyClientCommandEnum.h"
- #include "dataType/NettyClientResultMsg.h"
- #include "dataType/NettyServerCommandEnum.h"
- #include "dataType/NettyServerResultMsg.h"
- #include "dataType/RecDeviceCommand.h"
- #include "dataType/RecDeviceInfo.h"
- #include "dataType/SendLogin.h"
- #include "dataType/SendHeartBeat.h"
- #include "dataType/SendDevice.h"
- #include "dataType/SendBird.h"
- namespace HWYolov3App
- {
- class ProtoBuffer;
- class IYuvDataSrc;
- class Yolov3App
- {
- public:
- virtual ~Yolov3App(void);
- int32_t Init(std::string &appName);
- int32_t SetYuvChanAttr(sdc_yuv_channel_param_s &yuv_param);
- int32_t LoadModel(unsigned int loadMode, std::string &modelName);
- virtual int32_t NNieParamInit(void);
- int32_t SubscribeYuvDataAndForward(std::shared_ptr<IYuvDataSrc> dataSrc);
- void SubscribeSerEpoll(std::shared_ptr<tcpSerEpoll> serEpoll);
- void SubscribeCTimer(std::shared_ptr<CTimer> heartbeatTimer, std::shared_ptr<CTimer> closeExpelTimer);
- void Destroy(void);
- uint32_t GetYuvChannelId(void) const;
- protected:
- Yolov3App(void);
- virtual void PreProcessYuvData(sdc_yuv_frame_s &frame, uint8_t *&yuv);
- virtual void PretreatObjectData(SDC_SSD_OBJECT_INFO_S &data) = 0;
- bool ConstructRectAreaData(const SDC_SSD_OBJECT_INFO_S &data, ProtoBuffer &buf);
- bool ConstructTargetData(const SDC_SSD_OBJECT_INFO_S &data, ProtoBuffer &buf);
-
- // 将uclass对应的数字,映射为具体目标,目标信息不能超过20字符
- virtual void ClassifyTargets(uint32_t uclass, uint8_t target[20]) = 0;
- // 打印目标检测信息
- virtual void PrintObjectInfo(const SDC_SSD_OBJECT_INFO_S &info) const;
- virtual void SendObjectsToWeb(const SDC_SSD_RESULT_S &stResult, sdc_yuv_frame_s &yuvFrame) = 0;
- virtual void SendOjbectsToMediaServer(const SDC_SSD_RESULT_S &stResult) = 0;
- static void SendHeartbeatData(void *arg);
- static void sendCloseExpelData(void *arg);
-
- SDC_SSD_INPUT_SIZE_S m_videoSize; // 输入模型的大小
- SDC_SSD_INPUT_SIZE_S m_inputSize; // 输入模型的大小
- // Yuv循环队列的默认大小为50
- static const int32_t MAX_YUV_BUF_NUM = 50;
- static float m_confidenceThres; // 置信度阈值
- // 定时器
- std::shared_ptr<tcpSerEpoll> m_serEpoll;
- std::shared_ptr<CTimer> m_heartbeatTimer;
- std::shared_ptr<CTimer> m_closeExpelTimer;
- int m_fdResultFifo = -1;
- std::string m_resultFifo = "/tmp/result";
- const std::string m_configSrc = "../config/config.ini";
- // 数据订阅
- int m_USER_DET_IMG_W = 960; // 指定订阅使用的检测分辨率宽
- int m_USER_DET_IMG_H = 544; // 指定订阅使用的检测分辨率高
- int m_USER_DET_FRAME_RATE = 25; // 指定订阅帧率
- int m_MODEL_INPUT_SIZE_WIDTH = 416; // 模型输入大小宽
- int m_MODEL_INPUT_SIZE_HEIGHT = 416; // 模型输入大小高
- private:
- Yolov3App(const Yolov3App&);
- Yolov3App& operator=(const Yolov3App&);
- Yolov3App(Yolov3App&&);
- Yolov3App& operator=(Yolov3App&&);
- // 构造元数据
- bool ConstructMetaData(const SDC_SSD_RESULT_S &stResult, ProtoBuffer &buf);
- // 处理线程函数
- static void* YuvDataProcThrd(void *arg); // YUV处理线程
- static void* VideoSrvReadThrd(void *arg); // 视频服务线程
- static void* WatchdogThread(void *arg); // 系统资源监控
- // 卸载NNiE WK模型
- int32_t UnLoadModel(void);
- // 展示检测目标信息
- void SendObjectsToSims(ProtoBuffer &buf, int32_t pts) const;
- std::string m_appName;
- std::string m_modelName;
- // ReceiveThread & ProcessThread
- pthread_t m_tidpProc;
- pthread_t m_tidpRecv;
- pthread_t m_tidpWatchdog;
- uint32_t m_yuvChnId;
- YuvQueue m_yuvQue; // 循环队列保存Yuv数据帧
- std::shared_ptr<IYuvDataSrc> m_dataSrc; // 指定数据源
- };
- }
- #endif /* __YOLOV3_APP_H__ */
|