Commit e2a56ab342476fd296ec16112f3514dcfb9b2a72
1 parent
06edc90d
置信度添加
Showing
9 changed files
with
89 additions
and
30 deletions
src/left_over/ConExtraction.cpp
@@ -55,6 +55,7 @@ CConExtraction::~CConExtraction() | @@ -55,6 +55,7 @@ CConExtraction::~CConExtraction() | ||
55 | *******************************************************************************/ | 55 | *******************************************************************************/ |
56 | vector<CContour> CConExtraction::ExtractContours( | 56 | vector<CContour> CConExtraction::ExtractContours( |
57 | unsigned char *pSrcImage,// the point to the source imagedata | 57 | unsigned char *pSrcImage,// the point to the source imagedata |
58 | +float *MaskImgCfd, | ||
58 | const int &width, // the pixel number of each coloum | 59 | const int &width, // the pixel number of each coloum |
59 | const int &height, // the pixel number of each row(ÁÐ) | 60 | const int &height, // the pixel number of each row(ÁÐ) |
60 | const int &step // the byte number of each colum | 61 | const int &step // the byte number of each colum |
@@ -124,7 +125,7 @@ const int &step // the byte number of each colum | @@ -124,7 +125,7 @@ const int &step // the byte number of each colum | ||
124 | origin.x = x; | 125 | origin.x = x; |
125 | origin.y = y; | 126 | origin.y = y; |
126 | 127 | ||
127 | - m_contour = FetchContour(img + step * y + x, step, origin); | 128 | + m_contour = FetchContour(img + step * y + x, MaskImgCfd, step, origin); |
128 | 129 | ||
129 | // for debug use | 130 | // for debug use |
130 | //m_contour.label=0; | 131 | //m_contour.label=0; |
@@ -240,6 +241,7 @@ const int &step | @@ -240,6 +241,7 @@ const int &step | ||
240 | *******************************************************************************/ | 241 | *******************************************************************************/ |
241 | CContour CConExtraction::FetchContour( | 242 | CContour CConExtraction::FetchContour( |
242 | unsigned char *pImage, // the pointer to the starting pixel position value of the external contour | 243 | unsigned char *pImage, // the pointer to the starting pixel position value of the external contour |
244 | +float * cfg, | ||
243 | const int &step, // the byte number of each colum | 245 | const int &step, // the byte number of each colum |
244 | iCPoint &pt // the starting point position of the external contour | 246 | iCPoint &pt // the starting point position of the external contour |
245 | ) | 247 | ) |
@@ -339,7 +341,25 @@ iCPoint &pt // the starting point position of the external contour | @@ -339,7 +341,25 @@ iCPoint &pt // the starting point position of the external contour | ||
339 | m_Contour.bottom = m_rect.bottom; | 341 | m_Contour.bottom = m_rect.bottom; |
340 | m_Contour.xCenter = (m_Contour.left + m_Contour.right) / 2; | 342 | m_Contour.xCenter = (m_Contour.left + m_Contour.right) / 2; |
341 | m_Contour.yCenter = (m_Contour.top + m_Contour.bottom) / 2; | 343 | m_Contour.yCenter = (m_Contour.top + m_Contour.bottom) / 2; |
342 | - m_Contour.label = true; | 344 | + int count = 0; |
345 | + double totalCfd = 0; | ||
346 | + for (auto item : m_Pointvec) | ||
347 | + { | ||
348 | + if (cfg[item.y * step + item.x] > 0.001) | ||
349 | + { | ||
350 | + totalCfd += cfg[item.y * step + item.x]; | ||
351 | + ++count; | ||
352 | + } | ||
353 | + } | ||
354 | + if (count) | ||
355 | + { | ||
356 | + m_Contour.cfd = totalCfd / count; | ||
357 | + m_Contour.label = true; | ||
358 | + } | ||
359 | + else | ||
360 | + { | ||
361 | + m_Contour.label = false; | ||
362 | + } | ||
343 | } | 363 | } |
344 | else | 364 | else |
345 | { | 365 | { |
@@ -349,6 +369,7 @@ iCPoint &pt // the starting point position of the external contour | @@ -349,6 +369,7 @@ iCPoint &pt // the starting point position of the external contour | ||
349 | m_Contour.bottom = 0; | 369 | m_Contour.bottom = 0; |
350 | m_Contour.xCenter = 0; | 370 | m_Contour.xCenter = 0; |
351 | m_Contour.yCenter = 0; | 371 | m_Contour.yCenter = 0; |
372 | + m_Contour.cfd = 0; | ||
352 | m_Contour.label = false; | 373 | m_Contour.label = false; |
353 | } | 374 | } |
354 | } | 375 | } |
@@ -360,6 +381,7 @@ iCPoint &pt // the starting point position of the external contour | @@ -360,6 +381,7 @@ iCPoint &pt // the starting point position of the external contour | ||
360 | m_Contour.bottom = 0; | 381 | m_Contour.bottom = 0; |
361 | m_Contour.xCenter = 0; | 382 | m_Contour.xCenter = 0; |
362 | m_Contour.yCenter = 0; | 383 | m_Contour.yCenter = 0; |
384 | + m_Contour.cfd = 0; | ||
363 | m_Contour.label = false; | 385 | m_Contour.label = false; |
364 | } | 386 | } |
365 | 387 |
src/left_over/ConExtraction.h
@@ -35,6 +35,7 @@ typedef struct CContour | @@ -35,6 +35,7 @@ typedef struct CContour | ||
35 | int bottom; | 35 | int bottom; |
36 | int xCenter; | 36 | int xCenter; |
37 | int yCenter; | 37 | int yCenter; |
38 | + float cfd; | ||
38 | bool label; | 39 | bool label; |
39 | }CContour; // the detected target external contour of the current frame | 40 | }CContour; // the detected target external contour of the current frame |
40 | 41 | ||
@@ -63,7 +64,7 @@ public: | @@ -63,7 +64,7 @@ public: | ||
63 | virtual ~CConExtraction(); | 64 | virtual ~CConExtraction(); |
64 | 65 | ||
65 | public: | 66 | public: |
66 | - vector<CContour> ExtractContours (unsigned char *pSrcImage, const int &width, const int &height, const int &step); | 67 | + vector<CContour> ExtractContours (unsigned char *pSrcImage, float *MaskImgCfd, const int &width, const int &height, const int &step); |
67 | 68 | ||
68 | //vector<CForegroundTarget> DetectTarget(unsigned char *pSrcImage, const int &width, const int &height, const int &step); | 69 | //vector<CForegroundTarget> DetectTarget(unsigned char *pSrcImage, const int &width, const int &height, const int &step); |
69 | 70 | ||
@@ -77,7 +78,7 @@ private: | @@ -77,7 +78,7 @@ private: | ||
77 | iRect m_rect; //the rectangle of the contour | 78 | iRect m_rect; //the rectangle of the contour |
78 | 79 | ||
79 | private: | 80 | private: |
80 | - CContour FetchContour(unsigned char *pImage, const int &step, iCPoint &pt); | 81 | + CContour FetchContour(unsigned char *pImage, float * cfg, const int &step, iCPoint &pt); |
81 | 82 | ||
82 | void BoundingRect(vector<iCPoint> Pointvec); //get the corresponding rectangle of a point set | 83 | void BoundingRect(vector<iCPoint> Pointvec); //get the corresponding rectangle of a point set |
83 | 84 |
src/left_over/MSRegionSurveilance.h
@@ -99,6 +99,7 @@ struct CForeground | @@ -99,6 +99,7 @@ struct CForeground | ||
99 | { | 99 | { |
100 | CMRect m_rtConnect; | 100 | CMRect m_rtConnect; |
101 | CMPoint m_ptCenter; | 101 | CMPoint m_ptCenter; |
102 | + float m_cfd; | ||
102 | }; | 103 | }; |
103 | 104 | ||
104 | typedef struct CTarget | 105 | typedef struct CTarget |
@@ -152,6 +153,7 @@ typedef struct CTarget | @@ -152,6 +153,7 @@ typedef struct CTarget | ||
152 | long nFrameCurr; // 记录当前逗留帧数 | 153 | long nFrameCurr; // 记录当前逗留帧数 |
153 | int lastFrame; // 上次监测到逗留距离当前的帧数 | 154 | int lastFrame; // 上次监测到逗留距离当前的帧数 |
154 | CMRect m_TarBox; | 155 | CMRect m_TarBox; |
156 | + float cfd; | ||
155 | int dwGlobalID; | 157 | int dwGlobalID; |
156 | }CTarget; | 158 | }CTarget; |
157 | 159 | ||
@@ -177,6 +179,7 @@ typedef struct MS_ObjectInfo { | @@ -177,6 +179,7 @@ typedef struct MS_ObjectInfo { | ||
177 | MS_Trace trace; // 轨迹及报警状态 | 179 | MS_Trace trace; // 轨迹及报警状态 |
178 | int UniqueID; // 当前目标的特点ID | 180 | int UniqueID; // 当前目标的特点ID |
179 | CMRect TarBox; // 目标外接矩形 | 181 | CMRect TarBox; // 目标外接矩形 |
182 | + float confidence; // 置信度 | ||
180 | bool pbAlarmState[MAXROINUM]; // 对应区域是否报警 | 183 | bool pbAlarmState[MAXROINUM]; // 对应区域是否报警 |
181 | int pbAlarmType[MAXROINUM]; // 对应区域是哪种报警 | 184 | int pbAlarmType[MAXROINUM]; // 对应区域是哪种报警 |
182 | }MS_ObjectInfo; | 185 | }MS_ObjectInfo; |
@@ -190,6 +193,7 @@ public: | @@ -190,6 +193,7 @@ public: | ||
190 | int OBJECT_AREA_MAX; //默认最小过滤面积 by zl 20160304 | 193 | int OBJECT_AREA_MAX; //默认最小过滤面积 by zl 20160304 |
191 | int stay_dis; | 194 | int stay_dis; |
192 | unsigned char* MaskImgData; | 195 | unsigned char* MaskImgData; |
196 | + float* MaskImgCfd; | ||
193 | int gWinSize; | 197 | int gWinSize; |
194 | bool gfiltFlag; | 198 | bool gfiltFlag; |
195 | 199 |
src/left_over/MSRegionSurveilanceCpu.cpp
@@ -78,7 +78,7 @@ int IRegionSurveillanceCpu::rs_detect(const sy_img &img_data, region_info* regio | @@ -78,7 +78,7 @@ int IRegionSurveillanceCpu::rs_detect(const sy_img &img_data, region_info* regio | ||
78 | { | 78 | { |
79 | result->obj_infos[totalObjCount].curPos.x_ = ObjInfo[i].curPos.x+rect[k].left_; // 当前坐标 | 79 | result->obj_infos[totalObjCount].curPos.x_ = ObjInfo[i].curPos.x+rect[k].left_; // 当前坐标 |
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 | + result->obj_infos[totalObjCount].confidence = ObjInfo[i].confidence; |
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) |
@@ -115,7 +115,7 @@ int IRegionSurveillanceCpu::rs_detect(const sy_img &img_data, region_info* regio | @@ -115,7 +115,7 @@ int IRegionSurveillanceCpu::rs_detect(const sy_img &img_data, region_info* regio | ||
115 | { | 115 | { |
116 | result->del_infos[totalDelCount].curPos.x_ = DelInfo[i].curPos.x + rect[k].left_; // 当前坐标 | 116 | result->del_infos[totalDelCount].curPos.x_ = DelInfo[i].curPos.x + rect[k].left_; // 当前坐标 |
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 | + result->del_infos[totalDelCount].confidence = DelInfo[i].confidence; |
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) |
src/left_over/RegionSurveillanceProcess.h
@@ -2,7 +2,9 @@ | @@ -2,7 +2,9 @@ | ||
2 | #include "left_over_det.h" | 2 | #include "left_over_det.h" |
3 | #include <atomic> | 3 | #include <atomic> |
4 | #include "header.h" | 4 | #include "header.h" |
5 | +#ifndef _MSC_VER | ||
5 | #include "checkAuthor.h" | 6 | #include "checkAuthor.h" |
7 | +#endif | ||
6 | #define DEVICE_GPU 10 | 8 | #define DEVICE_GPU 10 |
7 | typedef struct rs_params | 9 | typedef struct rs_params |
8 | { | 10 | { |
@@ -63,7 +65,9 @@ public: | @@ -63,7 +65,9 @@ public: | ||
63 | bool init_flag = false; | 65 | bool init_flag = false; |
64 | sy_rect rect[MAXVERTEXNUM]; //有效区域 | 66 | sy_rect rect[MAXVERTEXNUM]; //有效区域 |
65 | unsigned char rect_num; //有效区域数量 | 67 | unsigned char rect_num; //有效区域数量 |
68 | +#ifndef _MSC_VER | ||
66 | CheckAuthor * auth = nullptr; | 69 | CheckAuthor * auth = nullptr; |
70 | +#endif | ||
67 | private: | 71 | private: |
68 | //int mode; //运行模式0 cpu | 72 | //int mode; //运行模式0 cpu |
69 | //MS_RegionSurveillance MS1; | 73 | //MS_RegionSurveillance MS1; |
src/left_over/left_over_det.h
@@ -92,7 +92,9 @@ typedef struct rs_param | @@ -92,7 +92,9 @@ typedef struct rs_param | ||
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; //有效区域数量 |
95 | +#ifndef _MSC_VER | ||
95 | rs_auth_config auth; | 96 | rs_auth_config auth; |
97 | +#endif | ||
96 | rs_auth_type type; | 98 | rs_auth_type type; |
97 | }rs_param; | 99 | }rs_param; |
98 | #endif | 100 | #endif |
@@ -111,12 +113,13 @@ typedef struct ms_trace { | @@ -111,12 +113,13 @@ typedef struct ms_trace { | ||
111 | #ifndef __RS_INFO__ | 113 | #ifndef __RS_INFO__ |
112 | #define __RS_INFO__ | 114 | #define __RS_INFO__ |
113 | typedef struct ms_object_info { | 115 | typedef struct ms_object_info { |
114 | - sy_point curPos; // 当前坐标 | 116 | + sy_point curPos; // 当前坐标 |
115 | ms_trace trace; // 轨迹及报警状态 | 117 | ms_trace trace; // 轨迹及报警状态 |
116 | int unique_id; // 当前目标的特点ID | 118 | int unique_id; // 当前目标的特点ID |
117 | - sy_rect tar_box; // 目标外接矩形 | ||
118 | - bool pb_alarm_state[MAXROINUM]; // 对应区域是否报警 | ||
119 | - int pb_alarm_type[MAXROINUM]; // 对应区域是哪种报警 | 119 | + sy_rect tar_box; // 目标外接矩形 |
120 | + float confidence; // 置信度 | ||
121 | + bool pb_alarm_state[MAXROINUM]; // 对应区域是否报警 | ||
122 | + int pb_alarm_type[MAXROINUM]; // 对应区域是哪种报警 | ||
120 | }ms_object_info; | 123 | }ms_object_info; |
121 | #endif | 124 | #endif |
122 | 125 |
src/left_over/ms_region_surveilance.cpp
@@ -124,13 +124,18 @@ int rs_init(void **handle, rs_param param) | @@ -124,13 +124,18 @@ int rs_init(void **handle, rs_param param) | ||
124 | bool auth_type = false; | 124 | bool auth_type = false; |
125 | if(param.type == PRODUCT_ID) | 125 | if(param.type == PRODUCT_ID) |
126 | { | 126 | { |
127 | +#ifndef _MSC_VER | ||
127 | char uuid[36] = {}; | 128 | char uuid[36] = {}; |
128 | FILE *Uuid = fopen("/proc/sys/kernel/random/uuid", "r"); | 129 | FILE *Uuid = fopen("/proc/sys/kernel/random/uuid", "r"); |
129 | fgets(uuid, 36, Uuid); | 130 | fgets(uuid, 36, Uuid); |
130 | fclose(Uuid); | 131 | fclose(Uuid); |
132 | + | ||
131 | regin->auth = new CheckAuthor; | 133 | regin->auth = new CheckAuthor; |
132 | regin->auth->Init(param.auth.url, param.auth.port, uuid, productSN, 1); | 134 | regin->auth->Init(param.auth.url, param.auth.port, uuid, productSN, 1); |
133 | auth_type = regin->auth->GetAuthorStatus(); | 135 | auth_type = regin->auth->GetAuthorStatus(); |
136 | +#else | ||
137 | + auth_type = true; | ||
138 | +#endif | ||
134 | } | 139 | } |
135 | if (param.type == TIME) | 140 | if (param.type == TIME) |
136 | { | 141 | { |
@@ -237,11 +242,13 @@ int rs_process(void *handle, sy_img img_data, rs_result *result) | @@ -237,11 +242,13 @@ int rs_process(void *handle, sy_img img_data, rs_result *result) | ||
237 | return -1; | 242 | return -1; |
238 | } | 243 | } |
239 | RegionSurveillanceProcess* regin = (RegionSurveillanceProcess*)handle; | 244 | RegionSurveillanceProcess* regin = (RegionSurveillanceProcess*)handle; |
245 | +#ifndef _MSC_VER | ||
240 | if (regin->type == PRODUCT_ID && (regin->auth && 0 == regin->auth->GetAuthorStatus())) | 246 | if (regin->type == PRODUCT_ID && (regin->auth && 0 == regin->auth->GetAuthorStatus())) |
241 | { | 247 | { |
242 | printf("auth error \n"); | 248 | printf("auth error \n"); |
243 | return -1; | 249 | return -1; |
244 | } | 250 | } |
251 | +#endif | ||
245 | region_info pRegionInfo; | 252 | region_info pRegionInfo; |
246 | pRegionInfo.alarm_info = 6; | 253 | pRegionInfo.alarm_info = 6; |
247 | pRegionInfo.frame_num = regin->frame_num; | 254 | pRegionInfo.frame_num = regin->frame_num; |
@@ -383,11 +390,13 @@ void rs_release(void **handle) | @@ -383,11 +390,13 @@ void rs_release(void **handle) | ||
383 | printf("handle is NULL \n"); | 390 | printf("handle is NULL \n"); |
384 | return; | 391 | return; |
385 | } | 392 | } |
393 | +#ifndef _MSC_VER | ||
386 | if (regin->type == PRODUCT_ID && regin->auth) | 394 | if (regin->type == PRODUCT_ID && regin->auth) |
387 | { | 395 | { |
388 | regin->auth->Uninit(); | 396 | regin->auth->Uninit(); |
389 | delete regin->auth; | 397 | delete regin->auth; |
390 | } | 398 | } |
399 | +#endif | ||
391 | delete regin; | 400 | delete regin; |
392 | regin = nullptr; | 401 | regin = nullptr; |
393 | } | 402 | } |
src/left_over/svibe.cpp
@@ -157,9 +157,11 @@ int RegionSurveillance::RSinit(int nWidth, int nHeight, int widthstep, unsigned | @@ -157,9 +157,11 @@ int RegionSurveillance::RSinit(int nWidth, int nHeight, int widthstep, unsigned | ||
157 | } | 157 | } |
158 | */ | 158 | */ |
159 | 159 | ||
160 | - MaskImgData = (unsigned char*) malloc(sizeof(unsigned char*) * GlobelWidth * GlobelHeight); | ||
161 | - memset(MaskImgData, 0, sizeof(unsigned char*)* GlobelWidth * GlobelHeight); | 160 | + MaskImgData = (unsigned char*) malloc(sizeof(unsigned char) * GlobelWidth * GlobelHeight); |
161 | + memset(MaskImgData, 0, sizeof(unsigned char)* GlobelWidth * GlobelHeight); | ||
162 | 162 | ||
163 | + MaskImgCfd = (float *)malloc(sizeof(float) * GlobelWidth * GlobelHeight); | ||
164 | + memset(MaskImgCfd, 0, sizeof(float)* GlobelWidth * GlobelHeight); | ||
163 | if (!vbM) | 165 | if (!vbM) |
164 | { | 166 | { |
165 | // 初始化模型 | 167 | // 初始化模型 |
@@ -371,7 +373,7 @@ VibeModel_t* RegionSurveillance::VibeModelInitC3(uint8_t *image_data) | @@ -371,7 +373,7 @@ VibeModel_t* RegionSurveillance::VibeModelInitC3(uint8_t *image_data) | ||
371 | return vbM; | 373 | return vbM; |
372 | } | 374 | } |
373 | 375 | ||
374 | -void RegionSurveillance::VibeModelUpdateC1(VibeModel_t *model, uint8_t *image, uint8_t *output) | 376 | +void RegionSurveillance::VibeModelUpdateC1(VibeModel_t *model, uint8_t *image, uint8_t *output, float * confidence) |
375 | { | 377 | { |
376 | int32_t x, y, xNG, yNG, count, index, dist, sampleOffset, imageOffset; | 378 | int32_t x, y, xNG, yNG, count, index, dist, sampleOffset, imageOffset; |
377 | uint32_t rand; | 379 | uint32_t rand; |
@@ -402,7 +404,7 @@ void RegionSurveillance::VibeModelUpdateC1(VibeModel_t *model, uint8_t *image, u | @@ -402,7 +404,7 @@ void RegionSurveillance::VibeModelUpdateC1(VibeModel_t *model, uint8_t *image, u | ||
402 | if (count < model->nMatch) | 404 | if (count < model->nMatch) |
403 | { | 405 | { |
404 | output[imageOffset] = VBPARAM->DEFAULT_COLOR_FOREGROUND; | 406 | output[imageOffset] = VBPARAM->DEFAULT_COLOR_FOREGROUND; |
405 | - | 407 | + confidence[imageOffset] = 1.00 - ((float)count / (float)model->nMatch); |
406 | if (g_frameCount < model->nSample) | 408 | if (g_frameCount < model->nSample) |
407 | { | 409 | { |
408 | rand = GetRand() % (model->nSample); | 410 | rand = GetRand() % (model->nSample); |
@@ -415,7 +417,7 @@ void RegionSurveillance::VibeModelUpdateC1(VibeModel_t *model, uint8_t *image, u | @@ -415,7 +417,7 @@ void RegionSurveillance::VibeModelUpdateC1(VibeModel_t *model, uint8_t *image, u | ||
415 | else | 417 | else |
416 | { | 418 | { |
417 | output[imageOffset] = VBPARAM->DEFAULT_COLOR_BACKGROUND; | 419 | output[imageOffset] = VBPARAM->DEFAULT_COLOR_BACKGROUND; |
418 | - | 420 | + confidence[imageOffset] = 0.00; |
419 | if (g_frameCount < model->nSample) | 421 | if (g_frameCount < model->nSample) |
420 | { | 422 | { |
421 | rand = GetRand() % (model->nSample); | 423 | rand = GetRand() % (model->nSample); |
@@ -699,7 +701,7 @@ void RegionSurveillance::RSDetect(unsigned char* frameImgData, RegionInfo* pRegi | @@ -699,7 +701,7 @@ void RegionSurveillance::RSDetect(unsigned char* frameImgData, RegionInfo* pRegi | ||
699 | delete[] inputData; | 701 | delete[] inputData; |
700 | } | 702 | } |
701 | 703 | ||
702 | - VibeModelUpdateC1(vbM, greyImgData, MaskImgData); | 704 | + VibeModelUpdateC1(vbM, greyImgData, MaskImgData, MaskImgCfd); |
703 | } | 705 | } |
704 | else | 706 | else |
705 | { | 707 | { |
@@ -729,7 +731,7 @@ void RegionSurveillance::RSDetect(unsigned char* frameImgData, RegionInfo* pRegi | @@ -729,7 +731,7 @@ void RegionSurveillance::RSDetect(unsigned char* frameImgData, RegionInfo* pRegi | ||
729 | delete[] inputData; | 731 | delete[] inputData; |
730 | } | 732 | } |
731 | 733 | ||
732 | - VibeModelUpdateC1(vbM, frameImgData, MaskImgData); | 734 | + VibeModelUpdateC1(vbM, frameImgData, MaskImgData, MaskImgCfd); |
733 | } | 735 | } |
734 | 736 | ||
735 | //VibeModelUpdateC1(vbM, greyImgData, MaskImgData); | 737 | //VibeModelUpdateC1(vbM, greyImgData, MaskImgData); |
@@ -748,7 +750,7 @@ void RegionSurveillance::RSDetect(unsigned char* frameImgData, RegionInfo* pRegi | @@ -748,7 +750,7 @@ void RegionSurveillance::RSDetect(unsigned char* frameImgData, RegionInfo* pRegi | ||
748 | */ | 750 | */ |
749 | 751 | ||
750 | //get trace | 752 | //get trace |
751 | - VibeModelGetTrace(MaskImgData, frameImgData, pRegionInfo); | 753 | + VibeModelGetTrace(MaskImgData, MaskImgCfd, frameImgData, pRegionInfo); |
752 | } | 754 | } |
753 | 755 | ||
754 | 756 | ||
@@ -1104,7 +1106,7 @@ void RegionSurveillance::SortForeground(vector<CForeground> &ForegroundArray) | @@ -1104,7 +1106,7 @@ void RegionSurveillance::SortForeground(vector<CForeground> &ForegroundArray) | ||
1104 | std::sort(ForegroundArray.begin(),ForegroundArray.end(), SortByPoint); | 1106 | std::sort(ForegroundArray.begin(),ForegroundArray.end(), SortByPoint); |
1105 | } | 1107 | } |
1106 | 1108 | ||
1107 | - | 1109 | +#include <math.h> |
1108 | int RegionSurveillance::dwGlobalID; | 1110 | int RegionSurveillance::dwGlobalID; |
1109 | /****************************************************************************** | 1111 | /****************************************************************************** |
1110 | * Function: VibeModelGetTrace | 1112 | * Function: VibeModelGetTrace |
@@ -1134,7 +1136,7 @@ int RegionSurveillance::dwGlobalID; | @@ -1134,7 +1136,7 @@ int RegionSurveillance::dwGlobalID; | ||
1134 | m_AlarmNum 报警编号 | 1136 | m_AlarmNum 报警编号 |
1135 | //m_TarBox 目标的外接矩形 | 1137 | //m_TarBox 目标的外接矩形 |
1136 | *******************************************************************************/ | 1138 | *******************************************************************************/ |
1137 | -void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, unsigned char* pRGBIn, RegionInfo* pRegionInfo) | 1139 | +void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *MaskImgCfd, unsigned char* pRGBIn, RegionInfo* pRegionInfo) |
1138 | { | 1140 | { |
1139 | /* | 1141 | /* |
1140 | memset(regionAlarm, 0, sizeof(bool) * MAXROINUM); | 1142 | memset(regionAlarm, 0, sizeof(bool) * MAXROINUM); |
@@ -1157,11 +1159,11 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, unsigned c | @@ -1157,11 +1159,11 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, unsigned c | ||
1157 | // 满足条件的(像素点 面积等条件100)前景外接矩形 | 1159 | // 满足条件的(像素点 面积等条件100)前景外接矩形 |
1158 | if (channel_num == 3) | 1160 | if (channel_num == 3) |
1159 | { | 1161 | { |
1160 | - foreContours = pConExtraction->ExtractContours(pSourceImg, GlobelWidth, GlobelHeight, GlobelWidthstep / 3); | 1162 | + foreContours = pConExtraction->ExtractContours(pSourceImg, MaskImgCfd,GlobelWidth, GlobelHeight, GlobelWidthstep / 3); |
1161 | } | 1163 | } |
1162 | else | 1164 | else |
1163 | { | 1165 | { |
1164 | - foreContours = pConExtraction->ExtractContours(pSourceImg, GlobelWidth, GlobelHeight, GlobelWidthstep); | 1166 | + foreContours = pConExtraction->ExtractContours(pSourceImg, MaskImgCfd, GlobelWidth, GlobelHeight, GlobelWidthstep); |
1165 | } | 1167 | } |
1166 | 1168 | ||
1167 | //轨迹匹配-zhm | 1169 | //轨迹匹配-zhm |
@@ -1176,8 +1178,8 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, unsigned c | @@ -1176,8 +1178,8 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, unsigned c | ||
1176 | testTarget.m_rtConnect.bottom = foreContours[i].bottom; | 1178 | testTarget.m_rtConnect.bottom = foreContours[i].bottom; |
1177 | testTarget.m_ptCenter.x = (testTarget.m_rtConnect.left + testTarget.m_rtConnect.right) / 2; | 1179 | testTarget.m_ptCenter.x = (testTarget.m_rtConnect.left + testTarget.m_rtConnect.right) / 2; |
1178 | testTarget.m_ptCenter.y = (testTarget.m_rtConnect.top + testTarget.m_rtConnect.bottom) / 2; | 1180 | testTarget.m_ptCenter.y = (testTarget.m_rtConnect.top + testTarget.m_rtConnect.bottom) / 2; |
1179 | - | ||
1180 | - | 1181 | + testTarget.m_cfd = foreContours[i].cfd; |
1182 | + | ||
1181 | //大于最小过滤面积且小于最大过滤面积 by zl 20160304 | 1183 | //大于最小过滤面积且小于最大过滤面积 by zl 20160304 |
1182 | int targetArea = abs((testTarget.m_rtConnect.left - testTarget.m_rtConnect.right) * (testTarget.m_rtConnect.top - testTarget.m_rtConnect.bottom)); | 1184 | int targetArea = abs((testTarget.m_rtConnect.left - testTarget.m_rtConnect.right) * (testTarget.m_rtConnect.top - testTarget.m_rtConnect.bottom)); |
1183 | if ( targetArea > OBJECT_AREA_MIN && targetArea < OBJECT_AREA_MAX) | 1185 | if ( targetArea > OBJECT_AREA_MIN && targetArea < OBJECT_AREA_MAX) |
@@ -1318,7 +1320,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, unsigned c | @@ -1318,7 +1320,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, unsigned c | ||
1318 | //m_TargetArray[dwBestMatch].m_AlarmState5 = false; | 1320 | //m_TargetArray[dwBestMatch].m_AlarmState5 = false; |
1319 | m_TargetArray[dwBestMatch].m_dwLostFrame = 0; | 1321 | m_TargetArray[dwBestMatch].m_dwLostFrame = 0; |
1320 | m_TargetArray[dwBestMatch].m_ptArray.push_back(ForegroundArray[i].m_ptCenter); | 1322 | m_TargetArray[dwBestMatch].m_ptArray.push_back(ForegroundArray[i].m_ptCenter); |
1321 | - | 1323 | + m_TargetArray[dwBestMatch].cfd = ForegroundArray[i].m_cfd; |
1322 | // Update current reference point | 1324 | // Update current reference point |
1323 | int dwPointCount = m_TargetArray[dwBestMatch].m_ptArray.size(); | 1325 | int dwPointCount = m_TargetArray[dwBestMatch].m_ptArray.size(); |
1324 | 1326 | ||
@@ -1395,6 +1397,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, unsigned c | @@ -1395,6 +1397,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, unsigned c | ||
1395 | m_TargetArray[dwBestMatch].m_CurRefPoint.y += (double)ForegroundArray[i].m_ptCenter.y / m_dwFrameWnd; | 1397 | m_TargetArray[dwBestMatch].m_CurRefPoint.y += (double)ForegroundArray[i].m_ptCenter.y / m_dwFrameWnd; |
1396 | 1398 | ||
1397 | m_TargetArray[dwBestMatch].m_TarBox = ForegroundArray[i].m_rtConnect; | 1399 | m_TargetArray[dwBestMatch].m_TarBox = ForegroundArray[i].m_rtConnect; |
1400 | + m_TargetArray[dwBestMatch].cfd = ForegroundArray[i].m_cfd; | ||
1398 | } | 1401 | } |
1399 | 1402 | ||
1400 | 1403 | ||
@@ -2102,6 +2105,8 @@ void RegionSurveillance::getObjectInfo(int ObjCount, MS_ObjectInfo* ObjInfo) | @@ -2102,6 +2105,8 @@ void RegionSurveillance::getObjectInfo(int ObjCount, MS_ObjectInfo* ObjInfo) | ||
2102 | { | 2105 | { |
2103 | int dwPointCount = m_FinalArray[i].m_ptArray.size(); | 2106 | int dwPointCount = m_FinalArray[i].m_ptArray.size(); |
2104 | ObjInfo[i].curPos = m_FinalArray[i].m_ptArray[dwPointCount - 1]; | 2107 | ObjInfo[i].curPos = m_FinalArray[i].m_ptArray[dwPointCount - 1]; |
2108 | + ObjInfo[i].confidence = m_FinalArray[i].cfd; | ||
2109 | + | ||
2105 | int temp_dwPointCount = dwPointCount; | 2110 | int temp_dwPointCount = dwPointCount; |
2106 | if (dwPointCount > MAXTRACENUM) | 2111 | if (dwPointCount > MAXTRACENUM) |
2107 | { | 2112 | { |
@@ -2149,7 +2154,8 @@ void RegionSurveillance::getObjectInfo(int ObjCount, MS_ObjectInfo* ObjInfo) | @@ -2149,7 +2154,8 @@ void RegionSurveillance::getObjectInfo(int ObjCount, MS_ObjectInfo* ObjInfo) | ||
2149 | */ | 2154 | */ |
2150 | // unique ID for current object | 2155 | // unique ID for current object |
2151 | ObjInfo[i].TarBox = m_FinalArray[i].m_TarBox; //目标外接矩形 | 2156 | ObjInfo[i].TarBox = m_FinalArray[i].m_TarBox; //目标外接矩形 |
2152 | - ObjInfo[i].UniqueID = m_FinalArray[i].m_dwID; //当前目标的特点ID | 2157 | + ObjInfo[i].UniqueID = m_FinalArray[i].m_dwID; //当前目标的特点ID |
2158 | + //printf("UniqueID = %d, cfd = %f\n", ObjInfo[i].UniqueID, ObjInfo[i].confidence); | ||
2153 | } | 2159 | } |
2154 | } | 2160 | } |
2155 | 2161 | ||
@@ -2161,6 +2167,7 @@ void RegionSurveillance::getDeleteInfo(int DelCount, MS_ObjectInfo* ObjInfo) | @@ -2161,6 +2167,7 @@ void RegionSurveillance::getDeleteInfo(int DelCount, MS_ObjectInfo* ObjInfo) | ||
2161 | { | 2167 | { |
2162 | int dwPointCount = m_DelArray[i].m_ptArray.size(); | 2168 | int dwPointCount = m_DelArray[i].m_ptArray.size(); |
2163 | ObjInfo[i].curPos = m_DelArray[i].m_ptArray[dwPointCount - 1]; | 2169 | ObjInfo[i].curPos = m_DelArray[i].m_ptArray[dwPointCount - 1]; |
2170 | + | ||
2164 | int temp_dwPointCount = dwPointCount; | 2171 | int temp_dwPointCount = dwPointCount; |
2165 | if (dwPointCount > MAXTRACENUM) | 2172 | if (dwPointCount > MAXTRACENUM) |
2166 | { | 2173 | { |
@@ -2208,7 +2215,8 @@ void RegionSurveillance::getDeleteInfo(int DelCount, MS_ObjectInfo* ObjInfo) | @@ -2208,7 +2215,8 @@ void RegionSurveillance::getDeleteInfo(int DelCount, MS_ObjectInfo* ObjInfo) | ||
2208 | */ | 2215 | */ |
2209 | // unique ID for current object | 2216 | // unique ID for current object |
2210 | ObjInfo[i].TarBox = m_DelArray[i].m_TarBox; //目标外接矩形 | 2217 | ObjInfo[i].TarBox = m_DelArray[i].m_TarBox; //目标外接矩形 |
2211 | - ObjInfo[i].UniqueID = m_DelArray[i].m_dwID; //当前目标的特点ID | 2218 | + ObjInfo[i].UniqueID = m_DelArray[i].m_dwID; //当前目标的特点ID |
2219 | + ObjInfo[i].confidence = m_DelArray[i].cfd; | ||
2212 | } | 2220 | } |
2213 | } | 2221 | } |
2214 | 2222 | ||
@@ -3340,6 +3348,13 @@ void RegionSurveillance::RSrelease() | @@ -3340,6 +3348,13 @@ void RegionSurveillance::RSrelease() | ||
3340 | //m_TargetArray.swap(vector<CTarget>(0)); | 3348 | //m_TargetArray.swap(vector<CTarget>(0)); |
3341 | //m_FinalArray.swap(vector<CTarget>(0)); | 3349 | //m_FinalArray.swap(vector<CTarget>(0)); |
3342 | 3350 | ||
3351 | + | ||
3352 | + if (MaskImgCfd != NULL) | ||
3353 | + { | ||
3354 | + free(MaskImgCfd); | ||
3355 | + MaskImgCfd = NULL; | ||
3356 | + } | ||
3357 | + | ||
3343 | if (MaskImgData != NULL) | 3358 | if (MaskImgData != NULL) |
3344 | { | 3359 | { |
3345 | free(MaskImgData); | 3360 | free(MaskImgData); |
src/left_over/svibe.h
@@ -29,7 +29,7 @@ typedef struct VIBEPARAM //by zl 20160520 代替宏定义 目的:可修改 | @@ -29,7 +29,7 @@ typedef struct VIBEPARAM //by zl 20160520 代替宏定义 目的:可修改 | ||
29 | int DEFAULT_COLOR_BACKGROUND; | 29 | int DEFAULT_COLOR_BACKGROUND; |
30 | int DEFAULT_COLOR_FOREGROUND; | 30 | int DEFAULT_COLOR_FOREGROUND; |
31 | int P_UPSPEED; | 31 | int P_UPSPEED; |
32 | - VIBEPARAM(int samples = 20, int threshold = 35, int p_match = 2, int bgcolor = 0, int forecolor = 255, int upspeed = 16) | 32 | + VIBEPARAM(int samples = 20, int threshold = 35, int p_match = 20, int bgcolor = 0, int forecolor = 255, int upspeed = 16) |
33 | { | 33 | { |
34 | P_SAMPLES = samples; | 34 | P_SAMPLES = samples; |
35 | P_THRESHOLD = threshold; | 35 | P_THRESHOLD = threshold; |
@@ -70,8 +70,8 @@ public: | @@ -70,8 +70,8 @@ public: | ||
70 | VibeModel_t* VibeModelInitC1(uint8_t *image_data); | 70 | VibeModel_t* VibeModelInitC1(uint8_t *image_data); |
71 | VibeModel_t* VibeModelInitC3(uint8_t *image_data); | 71 | VibeModel_t* VibeModelInitC3(uint8_t *image_data); |
72 | 72 | ||
73 | - void VibeModelGetTrace(unsigned char* inputdata,unsigned char* pRgbInData,RegionInfo* pRegionInfo); | ||
74 | - void VibeModelUpdateC1(VibeModel_t *model, uint8_t *image, uint8_t *output); | 73 | + void VibeModelGetTrace(unsigned char* inputdata, float *MaskImgCfd, unsigned char* pRgbInData,RegionInfo* pRegionInfo); |
74 | + void VibeModelUpdateC1(VibeModel_t *model, uint8_t *image, uint8_t *output, float * confidence); | ||
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, |
@@ -119,6 +119,7 @@ public: | @@ -119,6 +119,7 @@ public: | ||
119 | stay_dis = 5; | 119 | stay_dis = 5; |
120 | greyImgData = NULL; | 120 | greyImgData = NULL; |
121 | MaskImgData = NULL; | 121 | MaskImgData = NULL; |
122 | + MaskImgCfd = NULL; | ||
122 | gWinSize = 3; | 123 | gWinSize = 3; |
123 | g_randTable = NULL; | 124 | g_randTable = NULL; |
124 | g_XTable = NULL; | 125 | g_XTable = NULL; |