#ifndef __SNAPSHOT_H__ #define __SNAPSHOT_H__ #include "../VPT.h" #include #include #include #include //using namespace cv; const int SCALE_OUT = 10; //判断目标框初始位置时,在最小距离的基础上适当外扩 const int EDGESIZE = 4; typedef struct OBJECT_SNAPSHOT_INFO { VIDEO_OBJECT_SNAPSHOT objInfo; //快照基本信息(保存的最优信息) //unsigned char* objImg; //快照图像信息(保存最优图像) cv::Mat objImg; //快照图像信息(保存最优图像),我先用Mat方便,之后看是否改为char* int area; //改快照上一帧的面积(为了去除突变的快照) bitset flags; //标志位,标记快照框应该如何判断,left:0 top:1 right:2 bottom:3 vector voteIndex; }OBJECT_SNAPSHOT_INFO; // 220825 byzsh struct OBJ_KEY { string video_id; int obj_id; bool operator< (OBJ_KEY const& _A) const { if (strcmp(video_id.c_str(), _A.video_id.c_str()) < 0) return true; if (strcmp(video_id.c_str(), _A.video_id.c_str()) == 0) return obj_id < _A.obj_id; return false; } bool operator== (OBJ_KEY const& _A) const { if (strcmp(video_id.c_str(), _A.video_id.c_str())==0 && obj_id == _A.obj_id) return true; else return false; } }; class SnapShot { public: SnapShot(char* ResDir, VIDEO_OBJECT_SNAPSHOT_CALLBACK VideoObjSnapshotCallBack, SNAPSHOT_PARAMETER *ssParam); ~SnapShot(); void ResetSnapShot(); void SnapshotProcess(VPT_Result *result, cv::Mat img, vector deleteTrackers, int frameCount); void AddSnapshot(VPT_ObjInfo object, cv::Mat img, int frameCount); void UpdateSnapshot(VPT_ObjInfo object, cv::Mat img, int frameCount); void SaveSnapshot(vector deleteTrackers); void SnapshotProcessV2(VPT_Result *result, cv::Mat img, vector deleteTrackers, long frameCount, std::string video_key); //220825 byzsh void AddSnapshotV2(const OBJ_KEY &obj_key, VPT_ObjInfo object, cv::Mat img, long frameCount); //220825 byzsh void UpdateSnapshotV2(const OBJ_KEY &obj_key, VPT_ObjInfo object, cv::Mat img, long frameCount); //220825 byzsh void SaveSnapshotV2(vector deleteTrackers, std::string video_key); //220825 byzsh //辅助函数 bool LegalArea(int maxArea, int lastArea, int left, int top, int right, int bottom); bool LegalPos(bitset flags, int left, int top, int right, int bottom, int imgHeight, int imgWidth); bool saveSnapshot; //控制是否开启快照功能 public: char mResDir[260]; map snapshots; map snapshotsV2; //220825 byzsh VIDEO_OBJECT_SNAPSHOT_CALLBACK mVideoObjSnapshotCallBack; bool checkBoxSize, checkDistance; MRECT minBoxSize[DETECTTYPE]; int minDistance[EDGES]; boost::mutex threadMutex; boost::thread ProcessThread; vector deleteID; vector tempDeleteID; bool beginSaveSnapshot; int saveTimes; boost::mutex threadMutexV2; boost::thread ProcessThreadV2; vector deleteIDV2; vector tempDeleteIDV2; bool beginSaveSnapshotV2; int saveTimesV2; }; #endif // __SNAPSHOT_H__