Commit 06edc90d7b98b223350269eeed06b92aef26c9ea

Authored by Zou XiKun
1 parent dd731eff

每个区域目标最大数

src/left_over/MSRegionSurveilance.h
@@ -195,7 +195,7 @@ public: @@ -195,7 +195,7 @@ public:
195 195
196 196
197 // Ä£Ðͳõʼ»¯ 197 // Ä£Ðͳõʼ»¯
198 - virtual int RSinit(int nWidth, int nHeight, int widthstep, unsigned char* frameImgData, int nChannel, int nChannel_deal, bool nfiltFlag, int minArea = 0, int maxArea = 1000000) = 0; 198 + virtual int RSinit(int nWidth, int nHeight, int widthstep, unsigned char* frameImgData, int nChannel, int nChannel_deal, bool nfiltFlag, int maxObjNum, int minArea = 0, int maxArea = 1000000) = 0;
199 199
200 // ROIÇøÓò³õʼ»¯ 200 // ROIÇøÓò³õʼ»¯
201 virtual int RSRegion(int numROI, int alarm_info/*, bool iflog*/) = 0; 201 virtual int RSRegion(int numROI, int alarm_info/*, bool iflog*/) = 0;
src/left_over/MSRegionSurveilanceCpu.cpp
@@ -32,7 +32,7 @@ int IRegionSurveillanceCpu::rs_init(const rs_params &param) @@ -32,7 +32,7 @@ int IRegionSurveillanceCpu::rs_init(const rs_params &param)
32 Screenshot(gray, img, rect[i]); 32 Screenshot(gray, img, rect[i]);
33 //cv::Mat roi_img = cv::src_img(Range(0, 100), Range(50, 200)); 33 //cv::Mat roi_img = cv::src_img(Range(0, 100), Range(50, 200));
34 r = IReginCpu[i]->RSinit(img->width, img->height, img->width, 34 r = IReginCpu[i]->RSinit(img->width, img->height, img->width,
35 - (unsigned char*)(img->imageData), 1/*param.image.c_*/, 1/*param.channel_deal*/, param.filt_flag, param.min_area, param.max_area); 35 + (unsigned char*)(img->imageData), 1/*param.image.c_*/, 1/*param.channel_deal*/, param.filt_flag, param.max_obj_num, param.min_area, param.max_area);
36 cvReleaseImage(&img); 36 cvReleaseImage(&img);
37 } 37 }
38 cvReleaseImage(&gray); 38 cvReleaseImage(&gray);
@@ -80,7 +80,7 @@ int IRegionSurveillanceCpu::rs_detect(const sy_img &img_data, region_info* regio @@ -80,7 +80,7 @@ int IRegionSurveillanceCpu::rs_detect(const sy_img &img_data, region_info* regio
80 result->obj_infos[totalObjCount].curPos.y_ = ObjInfo[i].curPos.y+rect[k].top_; // 当前坐标 80 result->obj_infos[totalObjCount].curPos.y_ = ObjInfo[i].curPos.y+rect[k].top_; // 当前坐标
81 81
82 result->obj_infos[totalObjCount].trace.trace_num = ObjInfo[i].trace.nTraceNum; // 轨迹及报警状态 82 result->obj_infos[totalObjCount].trace.trace_num = ObjInfo[i].trace.nTraceNum; // 轨迹及报警状态
83 - printf("nTraceNum = %d\n", ObjInfo[i].trace.nTraceNum); 83 + //printf("nTraceNum = %d\n", ObjInfo[i].trace.nTraceNum);
84 for (int j = 0; j < MAXTRACENUM; ++j) 84 for (int j = 0; j < MAXTRACENUM; ++j)
85 { 85 {
86 result->obj_infos[totalObjCount].trace.obj_trace[j].x_ = ObjInfo[i].trace.pObjTrace[j].x+rect[k].left_; 86 result->obj_infos[totalObjCount].trace.obj_trace[j].x_ = ObjInfo[i].trace.pObjTrace[j].x+rect[k].left_;
@@ -98,7 +98,7 @@ int IRegionSurveillanceCpu::rs_detect(const sy_img &amp;img_data, region_info* regio @@ -98,7 +98,7 @@ int IRegionSurveillanceCpu::rs_detect(const sy_img &amp;img_data, region_info* regio
98 result->obj_infos[totalObjCount].pb_alarm_type[j] = ObjInfo[i].pbAlarmType[j]; 98 result->obj_infos[totalObjCount].pb_alarm_type[j] = ObjInfo[i].pbAlarmType[j];
99 } 99 }
100 ++totalObjCount; 100 ++totalObjCount;
101 - if (totalObjCount >= MACDETECTOBJNUM) 101 + if (totalObjCount >= macDetectObjNum * rect_num)
102 { 102 {
103 toObjCountBreak = true; 103 toObjCountBreak = true;
104 break; 104 break;
@@ -117,7 +117,7 @@ int IRegionSurveillanceCpu::rs_detect(const sy_img &amp;img_data, region_info* regio @@ -117,7 +117,7 @@ int IRegionSurveillanceCpu::rs_detect(const sy_img &amp;img_data, region_info* regio
117 result->del_infos[totalDelCount].curPos.y_ = DelInfo[i].curPos.y + rect[k].top_; // 当前坐标 117 result->del_infos[totalDelCount].curPos.y_ = DelInfo[i].curPos.y + rect[k].top_; // 当前坐标
118 118
119 result->del_infos[totalDelCount].trace.trace_num = DelInfo[i].trace.nTraceNum; // 轨迹及报警状态 119 result->del_infos[totalDelCount].trace.trace_num = DelInfo[i].trace.nTraceNum; // 轨迹及报警状态
120 - printf("del_infos nTraceNum = %d\n", DelInfo[i].trace.nTraceNum); 120 + //printf("del_infos nTraceNum = %d\n", DelInfo[i].trace.nTraceNum);
121 for (int j = 0; j < MAXTRACENUM; ++j) 121 for (int j = 0; j < MAXTRACENUM; ++j)
122 { 122 {
123 result->del_infos[totalDelCount].trace.obj_trace[j].x_ = DelInfo[i].trace.pObjTrace[j].x + rect[k].left_; 123 result->del_infos[totalDelCount].trace.obj_trace[j].x_ = DelInfo[i].trace.pObjTrace[j].x + rect[k].left_;
@@ -135,7 +135,7 @@ int IRegionSurveillanceCpu::rs_detect(const sy_img &amp;img_data, region_info* regio @@ -135,7 +135,7 @@ int IRegionSurveillanceCpu::rs_detect(const sy_img &amp;img_data, region_info* regio
135 result->del_infos[totalDelCount].pb_alarm_type[j] = DelInfo[i].pbAlarmType[j]; 135 result->del_infos[totalDelCount].pb_alarm_type[j] = DelInfo[i].pbAlarmType[j];
136 } 136 }
137 ++totalDelCount; 137 ++totalDelCount;
138 - if (totalDelCount >= MACDETECTOBJNUM) 138 + if (totalDelCount >= macDetectObjNum * rect_num)
139 { 139 {
140 toDelCountBreak = true; 140 toDelCountBreak = true;
141 break; 141 break;
src/left_over/RegionSurveillanceProcess.h
@@ -15,8 +15,8 @@ typedef struct rs_params @@ -15,8 +15,8 @@ typedef struct rs_params
15 bool filt_flag; 15 bool filt_flag;
16 int min_area; 16 int min_area;
17 int max_area; 17 int max_area;
18 -  
19 - rs_params() :mode(DEVICE_GPU), gpuid(0), min_area(0), max_area(1000000) {}; 18 + int max_obj_num;
  19 + rs_params() :mode(DEVICE_GPU), gpuid(0), min_area(0), max_area(1000000), max_obj_num(0){};
20 }rs_params; 20 }rs_params;
21 21
22 class RegionSurveillanceProcess 22 class RegionSurveillanceProcess
@@ -54,6 +54,7 @@ public: @@ -54,6 +54,7 @@ public:
54 double scale; 54 double scale;
55 //int long_side; 55 //int long_side;
56 //int short_side; 56 //int short_side;
  57 + int macDetectObjNum;
57 rs_auth_type type; 58 rs_auth_type type;
58 std::atomic<bool> thrd_run; 59 std::atomic<bool> thrd_run;
59 int licence_status = -1; 60 int licence_status = -1;
src/left_over/left_over_det.h
@@ -24,7 +24,6 @@ @@ -24,7 +24,6 @@
24 #define m_BOUNDING_BOX_RATEMIN 0.001 24 #define m_BOUNDING_BOX_RATEMIN 0.001
25 #define m_BOUNDING_BOX_RATEMAX 100 25 #define m_BOUNDING_BOX_RATEMAX 100
26 #define MAXROINUM 10 // 最大ROI数 26 #define MAXROINUM 10 // 最大ROI数
27 -#define MACDETECTOBJNUM 10  
28 27
29 #ifdef __cplusplus 28 #ifdef __cplusplus
30 extern "C" 29 extern "C"
@@ -89,6 +88,7 @@ typedef enum rs_auth_type { @@ -89,6 +88,7 @@ typedef enum rs_auth_type {
89 typedef struct rs_param 88 typedef struct rs_param
90 { 89 {
91 long frame_num; //逗留时间 单位帧数 90 long frame_num; //逗留时间 单位帧数
  91 + long max_obj_num; //每个区域目标最大数
92 double scale; //缩小比例 92 double scale; //缩小比例
93 sy_rect rect[MAXVERTEXNUM]; //有效区域 93 sy_rect rect[MAXVERTEXNUM]; //有效区域
94 unsigned char rect_num; //有效区域数量 94 unsigned char rect_num; //有效区域数量
@@ -125,9 +125,9 @@ typedef struct ms_trace { @@ -125,9 +125,9 @@ typedef struct ms_trace {
125 typedef struct rs_result 125 typedef struct rs_result
126 { 126 {
127 int obj_count; 127 int obj_count;
128 - ms_object_info obj_infos[MACDETECTOBJNUM]; 128 + ms_object_info * obj_infos; //每个区域目标最大数 * 有效区域数量
129 int del_count; 129 int del_count;
130 - ms_object_info del_infos[MACDETECTOBJNUM]; 130 + ms_object_info * del_infos; //每个区域目标最大数 * 有效区域数量
131 }rs_result; 131 }rs_result;
132 #endif 132 #endif
133 /************************************************************************* 133 /*************************************************************************
src/left_over/ms_region_surveilance.cpp
@@ -152,7 +152,7 @@ int rs_init(void **handle, rs_param param) @@ -152,7 +152,7 @@ int rs_init(void **handle, rs_param param)
152 if (auth_type) 152 if (auth_type)
153 { 153 {
154 regin->frame_num = param.frame_num; 154 regin->frame_num = param.frame_num;
155 - 155 + regin->macDetectObjNum = param.max_obj_num;
156 156
157 regin->scale = param.scale; 157 regin->scale = param.scale;
158 regin->rect_num = param.rect_num; //有效区域数量 158 regin->rect_num = param.rect_num; //有效区域数量
@@ -304,7 +304,7 @@ int rs_process(void *handle, sy_img img_data, rs_result *result) @@ -304,7 +304,7 @@ int rs_process(void *handle, sy_img img_data, rs_result *result)
304 rs_params param; 304 rs_params param;
305 param.mode = 0; //运行模式(DEVICE_GPU / DEVICE_CPU) 305 param.mode = 0; //运行模式(DEVICE_GPU / DEVICE_CPU)
306 param.gpuid = 0; //指定显卡id 306 param.gpuid = 0; //指定显卡id
307 - //其余算法参数 如长短边等 307 + param.max_obj_num = regin->macDetectObjNum; //其余算法参数 如长短边等
308 308
309 param.image = image; 309 param.image = image;
310 param.channel_deal = 1; 310 param.channel_deal = 1;
src/left_over/svibe.cpp
@@ -127,9 +127,9 @@ int RegionSurveillance::get_ArrowDir(CMPoint pROI0, CMPoint pROI1, CMPoint dir) @@ -127,9 +127,9 @@ int RegionSurveillance::get_ArrowDir(CMPoint pROI0, CMPoint pROI1, CMPoint dir)
127 *******************************************************************************/ 127 *******************************************************************************/
128 128
129 int RegionSurveillance::RSinit(int nWidth, int nHeight, int widthstep, unsigned char* frameImgData, 129 int RegionSurveillance::RSinit(int nWidth, int nHeight, int widthstep, unsigned char* frameImgData,
130 - int nChannel, int nChannel_deal, bool nfiltFlag, int minArea, int maxArea) 130 + int nChannel, int nChannel_deal, bool nfiltFlag, int maxObjNum, int minArea, int maxArea)
131 { 131 {
132 - 132 + macDetectObjNum = maxObjNum;
133 if(nWidth < 600 || nHeight < 300) //Èç¹û³ß´ç¹ýС ÐÞ¸Ävibe²ÎÊý 133 if(nWidth < 600 || nHeight < 300) //Èç¹û³ß´ç¹ýС ÐÞ¸Ävibe²ÎÊý
134 VBPARAM = new VIBEPARAM(35, 18); 134 VBPARAM = new VIBEPARAM(35, 18);
135 else 135 else
@@ -987,7 +987,7 @@ void RegionSurveillance::VibeModelErosion2(unsigned char* inputdata, unsigned ch @@ -987,7 +987,7 @@ void RegionSurveillance::VibeModelErosion2(unsigned char* inputdata, unsigned ch
987 output[j] = 0; 987 output[j] = 0;
988 output[(height - 1)*width + j] = 0; 988 output[(height - 1)*width + j] = 0;
989 } 989 }
990 - for (int i = 1; i<height; i++) 990 + for (int i = 1; i<height-1; i++)
991 { 991 {
992 src = inputdata + i*width; 992 src = inputdata + i*width;
993 dst = output + i*width; 993 dst = output + i*width;
@@ -1232,11 +1232,11 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, unsigned c @@ -1232,11 +1232,11 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, unsigned c
1232 // Calculate distance matrix and determine every target's best match 1232 // Calculate distance matrix and determine every target's best match
1233 1233
1234 int dwForegroundCount = ForegroundArray.size(); 1234 int dwForegroundCount = ForegroundArray.size();
1235 - dwForegroundCount = dwForegroundCount > MACDETECTOBJNUM ? MACDETECTOBJNUM : dwForegroundCount;  
1236 - if (ForegroundArray.size() > MACDETECTOBJNUM) 1235 + dwForegroundCount = dwForegroundCount > macDetectObjNum ? macDetectObjNum : dwForegroundCount;
  1236 + if (ForegroundArray.size() > macDetectObjNum)
1237 { 1237 {
1238 size_t n = ForegroundArray.size(); 1238 size_t n = ForegroundArray.size();
1239 - for (int i = 0; i < n - MACDETECTOBJNUM; ++i) 1239 + for (int i = 0; i < n - macDetectObjNum; ++i)
1240 { 1240 {
1241 ForegroundArray.pop_back(); 1241 ForegroundArray.pop_back();
1242 } 1242 }
src/left_over/svibe.h
@@ -75,7 +75,7 @@ public: @@ -75,7 +75,7 @@ public:
75 void VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, uint8_t *output); 75 void VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, uint8_t *output);
76 76
77 int RSinit(int nWidth, int nHeight, int widthstep, unsigned char* frameImgData, 77 int RSinit(int nWidth, int nHeight, int widthstep, unsigned char* frameImgData,
78 - int nChannel, int nChannel_deal, bool nfiltFlag, int minArea, int maxArea); //1 78 + int nChannel, int nChannel_deal, bool nfiltFlag, int maxObjNum, int minArea, int maxArea); //1
79 int VPTinit(int mode, int gpuid, float threshold); 79 int VPTinit(int mode, int gpuid, float threshold);
80 int RSRegion(int numROI, int alarm_info/*, bool iflog*/); 80 int RSRegion(int numROI, int alarm_info/*, bool iflog*/);
81 //void vibeMask(int num, CMPoint *pPointList, bool *pRegion); 81 //void vibeMask(int num, CMPoint *pPointList, bool *pRegion);
@@ -134,6 +134,7 @@ private: @@ -134,6 +134,7 @@ private:
134 int GlobelHeight; 134 int GlobelHeight;
135 int GlobelWidthstep; 135 int GlobelWidthstep;
136 std::list<CTarget> indexInWander; 136 std::list<CTarget> indexInWander;
  137 + int macDetectObjNum;
137 //std::set<int> indexInWander; 138 //std::set<int> indexInWander;
138 CMPoint pStart, pEnd; //by zl 用于存储可通行方向箭头的两个端点 139 CMPoint pStart, pEnd; //by zl 用于存储可通行方向箭头的两个端点
139 140
src/test/demo.cpp
@@ -59,12 +59,13 @@ void algorthim_thread1() { @@ -59,12 +59,13 @@ void algorthim_thread1() {
59 void imag_ana_3channels() 59 void imag_ana_3channels()
60 { 60 {
61 //AlarmInfo 1进入禁区 2离开禁区 3单向越界 4双向越界 5徘徊 6丢包 61 //AlarmInfo 1进入禁区 2离开禁区 3单向越界 4双向越界 5徘徊 6丢包
62 - 62 +
63 void *tools = nullptr; 63 void *tools = nullptr;
64 rs_param param; 64 rs_param param;
65 param.frame_num = 10; 65 param.frame_num = 10;
66 - param.scale = 1;  
67 - param.rect_num = 2; 66 + param.scale = 2;
  67 + param.rect_num = 1;
  68 + param.max_obj_num = 2;
68 69
69 { 70 {
70 param.rect[1].left_ = 30; 71 param.rect[1].left_ = 30;
@@ -92,7 +93,7 @@ void imag_ana_3channels() @@ -92,7 +93,7 @@ void imag_ana_3channels()
92 93
93 94
94 char imgpath[260]; 95 char imgpath[260];
95 - CvCapture* video1 = cvCaptureFromFile("./test.mp4"); 96 + CvCapture* video1 = cvCaptureFromFile("./convert.mp4");
96 // 用opencv函数读取视频的一帧 97 // 用opencv函数读取视频的一帧
97 //IplImage * src = cvQueryFrame(video1); 98 //IplImage * src = cvQueryFrame(video1);
98 IplImage *src = cvQueryFrame(video1); 99 IplImage *src = cvQueryFrame(video1);
@@ -114,6 +115,8 @@ void imag_ana_3channels() @@ -114,6 +115,8 @@ void imag_ana_3channels()
114 syimg.set_data(srcscale->width, srcscale->height, srcscale->nChannels, (unsigned char *)srcscale->imageData); 115 syimg.set_data(srcscale->width, srcscale->height, srcscale->nChannels, (unsigned char *)srcscale->imageData);
115 116
116 rs_result result{}; 117 rs_result result{};
  118 + result.del_infos = new ms_object_info[param.max_obj_num * param.rect_num]{};
  119 + result.obj_infos = new ms_object_info[param.max_obj_num * param.rect_num]{};
117 rs_process(tools, syimg, &result); 120 rs_process(tools, syimg, &result);
118 if (result.del_count != 0) 121 if (result.del_count != 0)
119 { 122 {
@@ -176,6 +179,8 @@ void imag_ana_3channels() @@ -176,6 +179,8 @@ void imag_ana_3channels()
176 179
177 180
178 } 181 }
  182 + delete[] result.del_infos;
  183 + delete[] result.obj_infos;
179 //cvWriteFrame(writer, srcscale); 184 //cvWriteFrame(writer, srcscale);
180 185
181 // 图像显示 186 // 图像显示