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