Commit 1bfead76831930393faebadb9f854e72fc475689

Authored by Zou XiKun
1 parent ef488d9a

update

src/left_over/MSRegionSurveilance.cpp
@@ -14,7 +14,7 @@ IRegionSurveillance *MS_RegionSurveillance::GetMS_RS() @@ -14,7 +14,7 @@ IRegionSurveillance *MS_RegionSurveillance::GetMS_RS()
14 return MS_RS; 14 return MS_RS;
15 else 15 else
16 { 16 {
17 - exit(0); 17 + exit(0);
18 return NULL; 18 return NULL;
19 } 19 }
20 } 20 }
src/left_over/help.cpp
1 /************************************************************* 1 /*************************************************************
2 /* name: help.cpp 2 /* name: help.cpp
3 -/* Description: 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷  
4 -/* Purpose锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟较诧拷锟斤拷锟斤拷锟斤拷  
5 -/* 1 锟斤拷锟斤拷邪锟斤拷锟叫★拷锟 2 锟津交诧拷 3 锟斤拷锟斤拷锟斤拷 3 +/* Description: 辅助函数集合
  4 +/* Purpose:满足以下条件,合并两个框:
  5 +/* 1 大框中包含小框 2 框交叉 3 框相邻
6 /* Update Time: by zl 20160307 6 /* Update Time: by zl 20160307
7 **************************************************************/ 7 **************************************************************/
8 #include "help.h" 8 #include "help.h"
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 #include <stdio.h> 11 #include <stdio.h>
12 #include <algorithm> 12 #include <algorithm>
13 using namespace std; 13 using namespace std;
14 -//锟斤拷锟斤拷 14 +//排序
15 bool SortByPoint(const CForeground &C1,const CForeground &C2) 15 bool SortByPoint(const CForeground &C1,const CForeground &C2)
16 { 16 {
17 bool sign = false; 17 bool sign = false;
@@ -28,7 +28,7 @@ bool SortByPoint(const CForeground &amp;C1,const CForeground &amp;C2) @@ -28,7 +28,7 @@ bool SortByPoint(const CForeground &amp;C1,const CForeground &amp;C2)
28 return false; 28 return false;
29 } 29 }
30 30
31 -//锟接达拷 31 +//从大到
32 bool SortByArea(const CForeground &C1, const CForeground &C2) 32 bool SortByArea(const CForeground &C1, const CForeground &C2)
33 { 33 {
34 bool sign = false; 34 bool sign = false;
@@ -38,7 +38,7 @@ bool SortByArea(const CForeground &amp;C1, const CForeground &amp;C2) @@ -38,7 +38,7 @@ bool SortByArea(const CForeground &amp;C1, const CForeground &amp;C2)
38 return false; 38 return false;
39 } 39 }
40 40
41 -//锟叫讹拷x锟角凤拷锟节边斤拷锟斤拷 41 +//判断x是否在边界内
42 bool InRange(int x, int boundary1, int boundary2) 42 bool InRange(int x, int boundary1, int boundary2)
43 { 43 {
44 int max_b = boundary1 >= boundary2 ? boundary1 : boundary2; 44 int max_b = boundary1 >= boundary2 ? boundary1 : boundary2;
@@ -49,33 +49,33 @@ bool InRange(int x, int boundary1, int boundary2) @@ -49,33 +49,33 @@ bool InRange(int x, int boundary1, int boundary2)
49 return false; 49 return false;
50 } 50 }
51 51
52 -//锟斤拷锟节伙拷锟竭帮拷锟斤拷 52 +//相邻或者包含
53 bool NeighbourorSub(CForeground c1, CForeground c2) 53 bool NeighbourorSub(CForeground c1, CForeground c2)
54 { 54 {
55 - //c2锟斤拷锟侥碉拷锟斤拷c1锟节诧拷 锟斤拷要锟较诧拷 锟斤拷锟斤拷true 55 + //c2中心点在c1内部 需要合并 返回true
56 /*if (c2.m_ptCenter.x < c1.m_rtConnect.right && InRange(c2.m_ptCenter.y, c1.m_rtConnect.top, c1.m_rtConnect.bottom)) 56 /*if (c2.m_ptCenter.x < c1.m_rtConnect.right && InRange(c2.m_ptCenter.y, c1.m_rtConnect.top, c1.m_rtConnect.bottom))
57 return true; 57 return true;
58 else */ 58 else */
59 - //锟斤拷锟斤拷锟斤拷锟斤拷为c2一锟斤拷锟斤拷c1锟斤拷锟揭诧拷 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟竭帮拷锟斤拷 c2锟斤拷锟斤拷锟铰碉拷 锟斤拷锟斤拷 锟斤拷锟较碉拷 锟较讹拷锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷c1锟斤拷锟节诧拷 59 + //输入条件为c2一定在c1的右侧 因此若交叉或者包含 c2的左下点 或者 右上点 肯定至少有一个在c1的内部
60 if (c2.m_rtConnect.left <= c1.m_rtConnect.right) 60 if (c2.m_rtConnect.left <= c1.m_rtConnect.right)
61 { 61 {
62 - //锟斤拷锟斤拷锟斤拷锟竭斤拷锟斤拷 62 + //包含或者交叉
63 if (InRange(c2.m_rtConnect.bottom, c1.m_rtConnect.top, c1.m_rtConnect.bottom) || InRange(c2.m_rtConnect.top, c1.m_rtConnect.top, c1.m_rtConnect.bottom)) 63 if (InRange(c2.m_rtConnect.bottom, c1.m_rtConnect.top, c1.m_rtConnect.bottom) || InRange(c2.m_rtConnect.top, c1.m_rtConnect.top, c1.m_rtConnect.bottom))
64 return true; 64 return true;
65 - //锟较凤拷锟节斤拷 锟斤拷锟斤拷 锟铰凤拷锟节斤拷 65 + //上方邻近 或者 下方邻近
66 else if (abs(c1.m_rtConnect.top - c2.m_rtConnect.bottom) < MergeMinDistance || abs(c1.m_rtConnect.bottom - c2.m_rtConnect.top) < MergeMinDistance) 66 else if (abs(c1.m_rtConnect.top - c2.m_rtConnect.bottom) < MergeMinDistance || abs(c1.m_rtConnect.bottom - c2.m_rtConnect.top) < MergeMinDistance)
67 return true; 67 return true;
68 } 68 }
69 else if (InRange(c2.m_rtConnect.bottom, c1.m_rtConnect.top, c1.m_rtConnect.bottom) || InRange(c2.m_rtConnect.top, c1.m_rtConnect.top, c1.m_rtConnect.bottom)) 69 else if (InRange(c2.m_rtConnect.bottom, c1.m_rtConnect.top, c1.m_rtConnect.bottom) || InRange(c2.m_rtConnect.top, c1.m_rtConnect.top, c1.m_rtConnect.bottom))
70 { 70 {
71 - if((abs(c1.m_rtConnect.right - c2.m_rtConnect.left) < MergeMinDistance)) //c2 锟斤拷 c1 锟揭诧拷 锟节斤拷 71 + if((abs(c1.m_rtConnect.right - c2.m_rtConnect.left) < MergeMinDistance)) //c2 在 c1 右侧 邻近
72 return true; 72 return true;
73 } 73 }
74 74
75 return false; 75 return false;
76 } 76 }
77 77
78 -//锟较诧拷 78 +//合并
79 void MergeNeighborBox(vector<CForeground> &ForegroundArray) 79 void MergeNeighborBox(vector<CForeground> &ForegroundArray)
80 { 80 {
81 vector<CForeground>::iterator iter1 = ForegroundArray.begin(); 81 vector<CForeground>::iterator iter1 = ForegroundArray.begin();
@@ -84,23 +84,23 @@ void MergeNeighborBox(vector&lt;CForeground&gt; &amp;ForegroundArray) @@ -84,23 +84,23 @@ void MergeNeighborBox(vector&lt;CForeground&gt; &amp;ForegroundArray)
84 vector<CForeground>::iterator iter2 = iter1 + 1; 84 vector<CForeground>::iterator iter2 = iter1 + 1;
85 for (; iter2 != ForegroundArray.end(); ) 85 for (; iter2 != ForegroundArray.end(); )
86 { 86 {
87 - //if ((x2 <= iter1->m_rtConnect.right && y2 <= iter1->m_rtConnect.bottom && y2 >= iter1->m_rtConnect.top) || //锟斤拷锟叫★拷锟阶达拷锟  
88 - // (iter2->m_rtConnect.left <= iter1->m_rtConnect.right && iter2->m_rtConnect.bottom <= iter1->m_rtConnect.bottom && iter2->m_rtConnect.bottom >= iter1->m_rtConnect.top) || //锟津交诧拷 锟斤拷锟较斤拷锟节碉拷一锟斤拷锟斤拷锟斤拷  
89 - // (iter2->m_rtConnect.left <= iter1->m_rtConnect.right && iter2->m_rtConnect.top <= iter1->m_rtConnect.bottom && iter2->m_rtConnect.top >= iter1->m_rtConnect.top) ||//锟津交诧拷 锟斤拷锟铰斤拷锟节碉拷一锟斤拷锟斤拷锟斤拷  
90 - // iter2->m_rtConnect.left <= iter1->m_ptCenter.x && abs(iter2->m_rtConnect.bottom - iter1->m_rtConnect.top) < 10 ||//锟斤拷锟斤拷辖锟斤拷锟 87 + //if ((x2 <= iter1->m_rtConnect.right && y2 <= iter1->m_rtConnect.bottom && y2 >= iter1->m_rtConnect.top) || //大框含小框状况
  88 + // (iter2->m_rtConnect.left <= iter1->m_rtConnect.right && iter2->m_rtConnect.bottom <= iter1->m_rtConnect.bottom && iter2->m_rtConnect.bottom >= iter1->m_rtConnect.top) || //框交叉 左上角在第一个框内
  89 + // (iter2->m_rtConnect.left <= iter1->m_rtConnect.right && iter2->m_rtConnect.top <= iter1->m_rtConnect.bottom && iter2->m_rtConnect.top >= iter1->m_rtConnect.top) ||//框交叉 左下角在第一个框内
  90 + // iter2->m_rtConnect.left <= iter1->m_ptCenter.x && abs(iter2->m_rtConnect.bottom - iter1->m_rtConnect.top) < 10 ||//距离较近的
91 // iter2->m_rtConnect.left <= iter1->m_ptCenter.x && abs(iter2->m_rtConnect.top - iter1->m_rtConnect.bottom) < 10 || 91 // iter2->m_rtConnect.left <= iter1->m_ptCenter.x && abs(iter2->m_rtConnect.top - iter1->m_rtConnect.bottom) < 10 ||
92 - // distance < 20 //锟斤拷锟斤拷辖锟斤拷锟 92 + // distance < 20 //距离较近的
93 // ) 93 // )
94 if (NeighbourorSub(*iter1, *iter2)) 94 if (NeighbourorSub(*iter1, *iter2))
95 { 95 {
96 - //锟较诧拷 96 + //合并
97 iter1->m_rtConnect.left = min(iter1->m_rtConnect.left, iter2->m_rtConnect.left); 97 iter1->m_rtConnect.left = min(iter1->m_rtConnect.left, iter2->m_rtConnect.left);
98 iter1->m_rtConnect.bottom = max(iter1->m_rtConnect.bottom, iter2->m_rtConnect.bottom); 98 iter1->m_rtConnect.bottom = max(iter1->m_rtConnect.bottom, iter2->m_rtConnect.bottom);
99 iter1->m_rtConnect.right = max(iter1->m_rtConnect.right, iter2->m_rtConnect.right); 99 iter1->m_rtConnect.right = max(iter1->m_rtConnect.right, iter2->m_rtConnect.right);
100 iter1->m_rtConnect.top = min(iter1->m_rtConnect.top, iter2->m_rtConnect.top); 100 iter1->m_rtConnect.top = min(iter1->m_rtConnect.top, iter2->m_rtConnect.top);
101 iter1->m_ptCenter.x = (iter1->m_rtConnect.right + iter1->m_rtConnect.left) / 2; 101 iter1->m_ptCenter.x = (iter1->m_rtConnect.right + iter1->m_rtConnect.left) / 2;
102 iter1->m_ptCenter.y = (iter1->m_rtConnect.bottom + iter1->m_rtConnect.top) / 2; 102 iter1->m_ptCenter.y = (iter1->m_rtConnect.bottom + iter1->m_rtConnect.top) / 2;
103 - //删锟斤拷一锟斤拷 103 + //删除一个
104 iter2 = ForegroundArray.erase(iter2); 104 iter2 = ForegroundArray.erase(iter2);
105 iter1 = iter2; 105 iter1 = iter2;
106 iter1--; 106 iter1--;
@@ -108,8 +108,8 @@ void MergeNeighborBox(vector&lt;CForeground&gt; &amp;ForegroundArray) @@ -108,8 +108,8 @@ void MergeNeighborBox(vector&lt;CForeground&gt; &amp;ForegroundArray)
108 else 108 else
109 iter2++; 109 iter2++;
110 //else 110 //else
111 - // break; //锟斤拷锟斤拷ForegroundArray锟斤拷x锟斤拷锟斤拷锟斤拷锟斤拷 锟斤拷锟斤拷锟斤拷为锟斤拷锟斤拷锟角帮拷锟斤拷院喜锟斤拷锟斤拷锟斤拷锌锟斤拷锟斤拷锟揭伙拷锟揭诧拷锟揭拷喜锟斤拷锟  
112 - //锟斤拷锟斤拷锟斤拷前锟斤拷锟斤拷锟较合诧拷 锟斤拷锟斤拷一锟斤拷也锟斤拷锟斤拷锟斤拷希锟轿拷思锟斤拷偌锟斤拷锟斤拷锟斤拷锟斤拷 111 + // break; //由于ForegroundArray按x坐标排列 所以认为如果当前可以合并,则有可能下一个也需要合并;
  112 + //但若当前不符合合并 则下一个也不会符合(为了减少计算次数)
113 113
114 } 114 }
115 } 115 }
@@ -125,9 +125,9 @@ int checkTime() @@ -125,9 +125,9 @@ int checkTime()
125 nYear = info->tm_year + 1900; 125 nYear = info->tm_year + 1900;
126 nMonth = info->tm_mon + 1; 126 nMonth = info->tm_mon + 1;
127 nDay = info->tm_mday; 127 nDay = info->tm_mday;
128 - if (nYear != 2021)//2017锟斤拷1锟斤拷1锟秸版本锟斤拷锟斤拷 128 + if (nYear != 2021)//2017??1??1??汾????
129 { 129 {
130 - printf("锟芥本锟斤拷锟节o拷\n"); 130 + printf("版本过期!\n");
131 return -1; 131 return -1;
132 } 132 }
133 else 133 else
src/left_over/left_over_det.h
@@ -117,7 +117,7 @@ typedef struct ms_trace { @@ -117,7 +117,7 @@ typedef struct ms_trace {
117 ms_trace trace; // 轨迹及报警状态 117 ms_trace trace; // 轨迹及报警状态
118 int unique_id; // 当前目标的特点ID 118 int unique_id; // 当前目标的特点ID
119 sy_rect tar_box; // 目标外接矩形 119 sy_rect tar_box; // 目标外接矩形
120 - float confidence; // 置信度 120 + float confidence; // 置信度
121 bool pb_alarm_state[MAXROINUM]; // 对应区域是否报警 121 bool pb_alarm_state[MAXROINUM]; // 对应区域是否报警
122 int pb_alarm_type[MAXROINUM]; // 对应区域是哪种报警 122 int pb_alarm_type[MAXROINUM]; // 对应区域是哪种报警
123 }ms_object_info; 123 }ms_object_info;
src/left_over/svibe.cpp
1 -// svibe.cpp : 锟斤拷锟斤拷锟斤拷锟教ㄓ︼拷贸锟斤拷锟斤拷锟斤拷诘恪 1 +// svibe.cpp : 定义控制台应用程序的入口点。
2 #include <stdio.h> 2 #include <stdio.h>
3 #include <stddef.h> 3 #include <stddef.h>
4 #include "svibe.h" 4 #include "svibe.h"
@@ -13,20 +13,20 @@ @@ -13,20 +13,20 @@
13 #include "help.h" 13 #include "help.h"
14 #include "left_over_det.h" 14 #include "left_over_det.h"
15 /************************************************************************/ 15 /************************************************************************/
16 -/* 锟斤拷锟斤拷: get_ArrowDir() by zl */  
17 -/* 锟斤拷锟斤拷: 锟斤拷取锟斤拷锟斤拷锟斤拷锟斤拷诨锟斤拷萍锟酵凤拷锟斤拷锟斤拷锟斤拷说悖 */  
18 -/* 锟斤拷锟斤拷: pROI0&pROI1锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟剿点; */  
19 -/* dir锟斤拷确锟斤拷锟斤拷锟津警憋拷锟斤拷锟斤拷锟斤拷锟斤拷锟姐; */  
20 -/* 锟斤拷锟斤拷: 1:锟斤拷锟斤拷锟斤拷0:锟斤拷锟斤拷锟斤拷 */ 16 +/* 函数: get_ArrowDir() by zl */
  17 +/* 作用: 获取方向和用于绘制箭头的两个端点; */
  18 +/* 参数: pROI0&pROI1:拌线两个端点; */
  19 +/* dir:确定单向警报方向的坐标点; */
  20 +/* 返回: 1:正方向;0:负方向 */
21 /************************************************************************/ 21 /************************************************************************/
22 int RegionSurveillance::get_ArrowDir(CMPoint pROI0, CMPoint pROI1, CMPoint dir) 22 int RegionSurveillance::get_ArrowDir(CMPoint pROI0, CMPoint pROI1, CMPoint dir)
23 { 23 {
24 24
25 float distance = (float)abs(pROI0.y - pROI1.y); 25 float distance = (float)abs(pROI0.y - pROI1.y);
26 - //锟斤拷取锟斤拷锟斤拷  
27 - float k1, k2; //k1为原锟竭段碉拷斜锟斤拷 26 + //获取方向
  27 + float k1, k2; //k1为原线段的斜率
28 28
29 - if (pROI0.y > pROI1.y) //锟节帮拷锟竭匡拷锟斤拷图锟斤拷锟铰凤拷锟侥端点处锟斤拷锟斤拷 29 + if (pROI0.y > pROI1.y) //在拌线靠近图像下方的端点处画箭
30 { 30 {
31 pStart.x = pROI0.x; 31 pStart.x = pROI0.x;
32 pStart.y = pROI0.y; 32 pStart.y = pROI0.y;
@@ -37,18 +37,18 @@ int RegionSurveillance::get_ArrowDir(CMPoint pROI0, CMPoint pROI1, CMPoint dir) @@ -37,18 +37,18 @@ int RegionSurveillance::get_ArrowDir(CMPoint pROI0, CMPoint pROI1, CMPoint dir)
37 pStart.y = pROI1.y; 37 pStart.y = pROI1.y;
38 } 38 }
39 39
40 - if (pROI0.x != pROI1.x) //锟斤拷锟斤拷为一锟斤拷锟斤拷直锟斤拷 40 + if (pROI0.x != pROI1.x) //若不为一根垂直线
41 { 41 {
42 k1 = (float)(pROI0.y - pROI1.y) / (float)(pROI0.x - pROI1.x); 42 k1 = (float)(pROI0.y - pROI1.y) / (float)(pROI0.x - pROI1.x);
43 - if (k1 != 0) //锟斤拷锟斤拷为一锟斤拷平锟斤拷锟斤拷 43 + if (k1 != 0) //若不为一根平行线
44 { 44 {
45 k2 = -1 / k1; 45 k2 = -1 / k1;
46 46
47 47
48 - float b = pROI1.y - k1 * pROI1.x;//y = kx + b 锟斤拷锟斤拷系一图锟斤拷锟斤拷锟较讹拷锟斤拷为原锟姐,锟斤拷锟斤拷为x锟斤拷锟斤拷锟斤拷 锟斤拷锟斤拷为y锟斤拷锟斤拷锟斤拷 48 + float b = pROI1.y - k1 * pROI1.x;//y = kx + b 坐标系一图像左上顶点为原点,向右为x正方形 向下为y正方向
49 if ((k1 < 0 && (float)((float)dir.y - k1 * (float)dir.x - b) < 0)||(k1 > 0 && (float)((float)dir.y - k1 * (float)dir.x - b) > 0)) 49 if ((k1 < 0 && (float)((float)dir.y - k1 * (float)dir.x - b) < 0)||(k1 > 0 && (float)((float)dir.y - k1 * (float)dir.x - b) > 0))
50 { 50 {
51 - if (distance < 30) //锟斤拷锟斤拷锟斤拷y值锟斤拷锟斤拷锟叫∈憋拷锟斤拷锟斤拷弑冉隙锟 锟斤拷锟斤拷去20 锟斤拷锟杰碉拷锟铰硷拷头太锟斤拷 51 + if (distance < 30) //当两点y值差异较小时,垂线比较陡 若减去20 可能导致箭头太长
52 { 52 {
53 pEnd.x = pStart.x - 2; 53 pEnd.x = pStart.x - 2;
54 } 54 }
@@ -66,7 +66,7 @@ int RegionSurveillance::get_ArrowDir(CMPoint pROI0, CMPoint pROI1, CMPoint dir) @@ -66,7 +66,7 @@ int RegionSurveillance::get_ArrowDir(CMPoint pROI0, CMPoint pROI1, CMPoint dir)
66 } 66 }
67 pEnd.y = (int)((pEnd.x - pStart.x) * k2 + pStart.y); 67 pEnd.y = (int)((pEnd.x - pStart.x) * k2 + pStart.y);
68 } 68 }
69 - else //锟斤拷为水平锟斤拷 69 + else //若为水平线
70 { 70 {
71 pEnd.x = pStart.x; 71 pEnd.x = pStart.x;
72 if (dir.y > pStart.y) 72 if (dir.y > pStart.y)
@@ -77,7 +77,7 @@ int RegionSurveillance::get_ArrowDir(CMPoint pROI0, CMPoint pROI1, CMPoint dir) @@ -77,7 +77,7 @@ int RegionSurveillance::get_ArrowDir(CMPoint pROI0, CMPoint pROI1, CMPoint dir)
77 } 77 }
78 78
79 } 79 }
80 - else //锟斤拷为锟斤拷直锟斤拷 80 + else //若为垂直线
81 { 81 {
82 pEnd.y = pStart.y; 82 pEnd.y = pStart.y;
83 if (dir.x > pStart.x) 83 if (dir.x > pStart.x)
@@ -85,20 +85,20 @@ int RegionSurveillance::get_ArrowDir(CMPoint pROI0, CMPoint pROI1, CMPoint dir) @@ -85,20 +85,20 @@ int RegionSurveillance::get_ArrowDir(CMPoint pROI0, CMPoint pROI1, CMPoint dir)
85 else 85 else
86 pEnd.x = pStart.x - 20; 86 pEnd.x = pStart.x - 20;
87 } 87 }
88 - //锟斤拷止越锟斤拷 88 + //防止越界
89 pEnd.x = pEnd.x >= 0 ? pEnd.x : 0; 89 pEnd.x = pEnd.x >= 0 ? pEnd.x : 0;
90 pEnd.x = pEnd.x <= GlobelWidth ? pEnd.x : GlobelWidth; 90 pEnd.x = pEnd.x <= GlobelWidth ? pEnd.x : GlobelWidth;
91 pEnd.y = pEnd.y >= 0 ? pEnd.y : 0; 91 pEnd.y = pEnd.y >= 0 ? pEnd.y : 0;
92 pEnd.y = pEnd.y <= GlobelHeight ? pEnd.y : GlobelHeight; 92 pEnd.y = pEnd.y <= GlobelHeight ? pEnd.y : GlobelHeight;
93 93
94 - if (pROI0.x == pROI1.x) //锟斤拷为锟斤拷直锟斤拷 94 + if (pROI0.x == pROI1.x) //若为垂直线
95 { 95 {
96 if (pEnd.x > pStart.x) 96 if (pEnd.x > pStart.x)
97 return 1; 97 return 1;
98 else 98 else
99 return 0; 99 return 0;
100 } 100 }
101 - else if (k1 <= 0) //锟斤拷锟斤拷为锟斤拷直锟斤拷锟斤拷斜锟斤拷小锟节碉拷锟斤拷0锟斤拷锟斤拷水平锟斤拷锟斤拷锟斤拷锟 101 + else if (k1 <= 0) //若不为垂直线且斜率小于等于0(含水平线情况)
102 { 102 {
103 if ((pStart.x != pEnd.x && pEnd.x > pStart.x) || (pStart.x == pEnd.x && pEnd.y > pStart.y)) 103 if ((pStart.x != pEnd.x && pEnd.x > pStart.x) || (pStart.x == pEnd.x && pEnd.y > pStart.y))
104 return 0; 104 return 0;
@@ -116,26 +116,26 @@ int RegionSurveillance::get_ArrowDir(CMPoint pROI0, CMPoint pROI1, CMPoint dir) @@ -116,26 +116,26 @@ int RegionSurveillance::get_ArrowDir(CMPoint pROI0, CMPoint pROI1, CMPoint dir)
116 116
117 /****************************************************************************** 117 /******************************************************************************
118 * Function: RSinit 118 * Function: RSinit
119 -* Description: MaskImgData锟节达拷锟斤拷浼癡IBE 模锟酵筹拷始锟斤拷 119 +* Description: MaskImgData内存非配及VIBE 模型初始化
120 * Calls: VibeModelInitC3 120 * Calls: VibeModelInitC3
121 * Called By: main 121 * Called By: main
122 -* Input: nWidth 图锟斤拷锟斤拷锟  
123 - nHeight 图锟斤拷叨锟  
124 - frameImgData 图锟斤拷RGB  
125 -* Output: vbM VIBE 模锟斤拷  
126 -* Return: 0 锟斤拷锟斤拷通锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 1 锟斤拷锟斤拷 122 +* Input: nWidth 图像宽度
  123 + nHeight 图像高度
  124 + frameImgData 图像RGB
  125 +* Output: vbM VIBE 模型
  126 +* Return: 0 输入通道参数不合理 1 正常
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 maxObjNum, int minArea, int maxArea) 130 int nChannel, int nChannel_deal, bool nfiltFlag, int maxObjNum, int minArea, int maxArea)
131 { 131 {
132 macDetectObjNum = maxObjNum; 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
136 VBPARAM = new VIBEPARAM(20, 35); 136 VBPARAM = new VIBEPARAM(20, 35);
137 137
138 - //checkMID锟斤拷锟斤拷锟斤拷锟斤拷锟缴硷拷锟 by zl 138 + //checkMID???????????? by zl
139 if (/*checkMIDkeySet() == -1 */ /*checkTime() == -1 || */(nChannel != 1 && nChannel != 3) || (nChannel_deal != 1 && nChannel_deal != 3) || (nChannel_deal > nChannel)) 139 if (/*checkMIDkeySet() == -1 */ /*checkTime() == -1 || */(nChannel != 1 && nChannel != 3) || (nChannel_deal != 1 && nChannel_deal != 3) || (nChannel_deal > nChannel))
140 { 140 {
141 return 0; 141 return 0;
@@ -147,8 +147,8 @@ int RegionSurveillance::RSinit(int nWidth, int nHeight, int widthstep, unsigned @@ -147,8 +147,8 @@ int RegionSurveillance::RSinit(int nWidth, int nHeight, int widthstep, unsigned
147 GlobelHeight = nHeight; 147 GlobelHeight = nHeight;
148 GlobelWidthstep = widthstep; 148 GlobelWidthstep = widthstep;
149 gfiltFlag = nfiltFlag; 149 gfiltFlag = nfiltFlag;
150 - OBJECT_AREA_MIN = minArea; //默锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟轿,000,000 by zl 20160304  
151 - OBJECT_AREA_MAX = maxArea; //默锟斤拷锟斤拷小锟斤拷锟斤拷锟斤拷锟轿00 by zl 20160304 150 + OBJECT_AREA_MIN = minArea; //默认最大过滤面积为1,000,000 by zl 20160304
  151 + OBJECT_AREA_MAX = maxArea; //默认最小过滤面积为300 by zl 20160304
152 /* 152 /*
153 int widthstep = nWidth * 3; 153 int widthstep = nWidth * 3;
154 if (widthstep % 4) 154 if (widthstep % 4)
@@ -164,12 +164,12 @@ int RegionSurveillance::RSinit(int nWidth, int nHeight, int widthstep, unsigned @@ -164,12 +164,12 @@ int RegionSurveillance::RSinit(int nWidth, int nHeight, int widthstep, unsigned
164 memset(MaskImgCfd, 0, sizeof(float)* GlobelWidth * GlobelHeight); 164 memset(MaskImgCfd, 0, sizeof(float)* GlobelWidth * GlobelHeight);
165 if (!vbM) 165 if (!vbM)
166 { 166 {
167 - // 锟斤拷始锟斤拷模锟斤拷 167 + // 初始化模型
168 if (nChannel == 3) 168 if (nChannel == 3)
169 { 169 {
170 if (nChannel_deal == 3) 170 if (nChannel_deal == 3)
171 { 171 {
172 - // 锟斤拷斯模锟斤拷 172 + // 高斯模糊
173 if (nfiltFlag == 1) 173 if (nfiltFlag == 1)
174 { 174 {
175 unsigned char* inputData = NULL; 175 unsigned char* inputData = NULL;
@@ -207,10 +207,10 @@ int RegionSurveillance::RSinit(int nWidth, int nHeight, int widthstep, unsigned @@ -207,10 +207,10 @@ int RegionSurveillance::RSinit(int nWidth, int nHeight, int widthstep, unsigned
207 { 207 {
208 greyImgData = (unsigned char*) malloc(sizeof(unsigned char*) * GlobelWidth * nHeight); 208 greyImgData = (unsigned char*) malloc(sizeof(unsigned char*) * GlobelWidth * nHeight);
209 memset(greyImgData, 0, sizeof(unsigned char*)); 209 memset(greyImgData, 0, sizeof(unsigned char*));
210 - // 锟斤拷RGB图锟斤拷转锟斤拷为锟揭讹拷图锟斤拷 210 + // 将RGB图像转换为灰度图像
211 VibeRGBToGray(frameImgData, greyImgData); 211 VibeRGBToGray(frameImgData, greyImgData);
212 212
213 - // 锟斤拷斯模锟斤拷 213 + // 高斯模糊
214 if (nfiltFlag == 1) 214 if (nfiltFlag == 1)
215 { 215 {
216 unsigned char* inputData = NULL; 216 unsigned char* inputData = NULL;
@@ -241,7 +241,7 @@ int RegionSurveillance::RSinit(int nWidth, int nHeight, int widthstep, unsigned @@ -241,7 +241,7 @@ int RegionSurveillance::RSinit(int nWidth, int nHeight, int widthstep, unsigned
241 } 241 }
242 else 242 else
243 { 243 {
244 - // 锟斤拷斯模锟斤拷 244 + // 高斯模糊
245 if (nfiltFlag == 1) 245 if (nfiltFlag == 1)
246 { 246 {
247 unsigned char* inputData = NULL; 247 unsigned char* inputData = NULL;
@@ -272,10 +272,10 @@ int RegionSurveillance::RSinit(int nWidth, int nHeight, int widthstep, unsigned @@ -272,10 +272,10 @@ int RegionSurveillance::RSinit(int nWidth, int nHeight, int widthstep, unsigned
272 } 272 }
273 } 273 }
274 274
275 - left_flag = 1; // 锟斤拷锟斤拷锟斤拷志 0 锟斤拷锟斤拷 1锟狡筹拷 275 + left_flag = 1; // 逗留标志 0 遗留 1移除
276 276
277 - maskImg = new unsigned char[nWidth*nHeight]; //锟斤拷锟酵和革拷蚀 锟斤拷锟斤拷锟斤拷  
278 - memset(maskImg, 0, sizeof(maskImg[0])*nWidth*nHeight); //锟斤拷锟酵和革拷蚀 锟斤拷锟斤拷锟斤拷 277 + maskImg = new unsigned char[nWidth*nHeight]; //膨胀和腐蚀 加速用
  278 + memset(maskImg, 0, sizeof(maskImg[0])*nWidth*nHeight); //膨胀和腐蚀 加速用
279 279
280 return 1; 280 return 1;
281 } 281 }
@@ -319,17 +319,17 @@ VibeModel_t * RegionSurveillance::VibeModelInitC1(uint8_t *image_data) @@ -319,17 +319,17 @@ VibeModel_t * RegionSurveillance::VibeModelInitC1(uint8_t *image_data)
319 319
320 /****************************************************************************** 320 /******************************************************************************
321 * Function: VibeModelInitC3 321 * Function: VibeModelInitC3
322 -* Description: VIBE模锟酵筹拷始锟斤拷 322 +* Description: VIBE模型初始化
323 * Calls: RandInit 323 * Calls: RandInit
324 RandNeighborInit 324 RandNeighborInit
325 GetRandNeighborXY 325 GetRandNeighborXY
326 * Called By: RSinit 326 * Called By: RSinit
327 -* Input: image_data 图锟斤拷RGB 327 +* Input: image_data 图RGB
328 * Output: g_XNeighborTable 22100012 328 * Output: g_XNeighborTable 22100012
329 g_YNeighborTable 10001222 329 g_YNeighborTable 10001222
330 - g_randTable 65536锟斤拷锟斤拷锟斤拷锟  
331 - g_XTable 0 0 1 2 3 ... 锟斤拷锟斤拷-1 锟斤拷锟斤拷-1  
332 - g_YTable 0 0 1 2 3 ... 锟竭讹拷-1 锟竭讹拷-1 330 + g_randTable 65536个随机数
  331 + g_XTable 0 0 1 2 3 ... 宽度-1 宽度-1
  332 + g_YTable 0 0 1 2 3 ... 高度-1 高度-1
333 * Return: vbM 333 * Return: vbM
334 *******************************************************************************/ 334 *******************************************************************************/
335 VibeModel_t* RegionSurveillance::VibeModelInitC3(uint8_t *image_data) 335 VibeModel_t* RegionSurveillance::VibeModelInitC3(uint8_t *image_data)
@@ -449,11 +449,11 @@ void RegionSurveillance::VibeModelUpdateC1(VibeModel_t *model, uint8_t *image, u @@ -449,11 +449,11 @@ void RegionSurveillance::VibeModelUpdateC1(VibeModel_t *model, uint8_t *image, u
449 }// end of for y loop 449 }// end of for y loop
450 450
451 451
452 - VibeModelDilation2(output, maskImg, model->width, model->height);// 锟斤拷锟斤拷  
453 - VibeModelErosion2(maskImg, output, model->width, model->height);// 锟斤拷蚀  
454 - //未锟斤拷锟劫版本  
455 - //VibeModelDilation(output, model->width, model->height);// 锟斤拷锟斤拷  
456 - //VibeModelErosion(output, model->width, model->height);// 锟斤拷蚀 452 + VibeModelDilation2(output, maskImg, model->width, model->height);// 膨胀
  453 + VibeModelErosion2(maskImg, output, model->width, model->height);// 腐蚀
  454 + //未加速版本
  455 + //VibeModelDilation(output, model->width, model->height);// 膨胀
  456 + //VibeModelErosion(output, model->width, model->height);// 腐蚀
457 457
458 458
459 g_frameCount++; 459 g_frameCount++;
@@ -462,16 +462,16 @@ void RegionSurveillance::VibeModelUpdateC1(VibeModel_t *model, uint8_t *image, u @@ -462,16 +462,16 @@ void RegionSurveillance::VibeModelUpdateC1(VibeModel_t *model, uint8_t *image, u
462 462
463 /****************************************************************************** 463 /******************************************************************************
464 * Function: VibeModelUpdateC3 464 * Function: VibeModelUpdateC3
465 -* Description: VIBE模锟酵革拷锟斤拷 465 +* Description: VIBE模型更新
466 * Calls: GetRand 466 * Calls: GetRand
467 GetRandNeighborXY 467 GetRandNeighborXY
468 VibeModelDilation 468 VibeModelDilation
469 VibeModelErosion 469 VibeModelErosion
470 * Called By: RSDetect 470 * Called By: RSDetect
471 -* Input: model VBM 模锟斤拷  
472 - image 图锟斤拷RGB  
473 -* Output: output 前锟斤拷锟斤拷255 锟斤拷锟斤拷锟斤拷0  
474 - model VBM 模锟斤拷 471 +* Input: model VBM 模型
  472 + image 图像RGB
  473 +* Output: output 前景是255 背景是0
  474 + model VBM 模型
475 *******************************************************************************/ 475 *******************************************************************************/
476 void RegionSurveillance::VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, uint8_t *output) 476 void RegionSurveillance::VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, uint8_t *output)
477 { 477 {
@@ -487,10 +487,10 @@ void RegionSurveillance::VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, u @@ -487,10 +487,10 @@ void RegionSurveillance::VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, u
487 { 487 {
488 for (x = 0; x < model->width; x++) 488 for (x = 0; x < model->width; x++)
489 { 489 {
490 - // 锟斤拷前锟斤拷锟接︼拷锟侥o拷锟斤拷械锟斤拷锟斤拷锟 490 + // 当前点对应的模板中的索引
491 sampleOffset = ((y * model-> width * model->nSample + x * model->nSample) << 1) + (y * model-> width * model->nSample + x * model->nSample); 491 sampleOffset = ((y * model-> width * model->nSample + x * model->nSample) << 1) + (y * model-> width * model->nSample + x * model->nSample);
492 492
493 - // 锟斤拷前锟斤拷锟接︼拷锟絉GB锟叫碉拷锟斤拷锟斤拷 493 + // 当前点对应的RGB中的索引
494 imageOffset = ((y * model->width + x) << 1) + (y * model->width + x); 494 imageOffset = ((y * model->width + x) << 1) + (y * model->width + x);
495 495
496 // if (imageOffset>=(model->width * model->height)) 496 // if (imageOffset>=(model->width * model->height))
@@ -500,7 +500,7 @@ void RegionSurveillance::VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, u @@ -500,7 +500,7 @@ void RegionSurveillance::VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, u
500 count = 0; 500 count = 0;
501 index = 0; 501 index = 0;
502 502
503 - // 锟斤拷锟斤拷锟角帮拷锟斤拷锟斤拷锟街碉拷牡锟斤拷锟叫★拷诠娑ㄆワ拷锟斤拷锟斤拷 锟斤拷 锟斤拷前锟斤拷锟斤拷锟侥碉拷锟斤拷小锟斤拷20锟斤拷锟斤拷 503 + // 如果当前满足阈值的点数小于规定匹配点数 且 当前评估的点数小于20个点
504 while ((count < model->nMatch) && (index < model->nSample)) 504 while ((count < model->nMatch) && (index < model->nSample))
505 { 505 {
506 //Euclidean distance computation 506 //Euclidean distance computation
@@ -508,10 +508,10 @@ void RegionSurveillance::VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, u @@ -508,10 +508,10 @@ void RegionSurveillance::VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, u
508 dist = (double)((image[imageOffset] - model->bg_samples[tmpValue ])*(image[imageOffset] - model->bg_samples[tmpValue])) + 508 dist = (double)((image[imageOffset] - model->bg_samples[tmpValue ])*(image[imageOffset] - model->bg_samples[tmpValue])) +
509 (double)((image[imageOffset + 1] - model->bg_samples[tmpValue + 1])*(image[imageOffset + 1] - model->bg_samples[tmpValue+ 1])) + 509 (double)((image[imageOffset + 1] - model->bg_samples[tmpValue + 1])*(image[imageOffset + 1] - model->bg_samples[tmpValue+ 1])) +
510 (double)((image[imageOffset + 2] - model->bg_samples[tmpValue + 2])*(image[imageOffset + 2] - model->bg_samples[tmpValue + 2])); 510 (double)((image[imageOffset + 2] - model->bg_samples[tmpValue + 2])*(image[imageOffset + 2] - model->bg_samples[tmpValue + 2]));
511 - // 锟斤拷通锟斤拷锟斤拷锟斤拷锟斤拷锟街拷锟 511 + // 三通道计算距离之和
512 //dist = abs(image[imageOffset] - model->bg_samples[tmpValue]) + abs(image[imageOffset + 1] - model->bg_samples[tmpValue + 1]) 512 //dist = abs(image[imageOffset] - model->bg_samples[tmpValue]) + abs(image[imageOffset + 1] - model->bg_samples[tmpValue + 1])
513 //+ abs(image[imageOffset + 2] - model->bg_samples[tmpValue + 2]); 513 //+ abs(image[imageOffset + 2] - model->bg_samples[tmpValue + 2]);
514 - // 锟斤拷锟斤拷锟斤拷值锟斤拷锟斤拷锟侥碉拷 514 + // 满足阈值条件的点
515 if (dist < model->threshold * model->threshold * 3) 515 if (dist < model->threshold * model->threshold * 3)
516 { 516 {
517 count++; 517 count++;
@@ -520,22 +520,22 @@ void RegionSurveillance::VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, u @@ -520,22 +520,22 @@ void RegionSurveillance::VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, u
520 index++; 520 index++;
521 } 521 }
522 522
523 - // 锟斤拷锟斤拷锟角帮拷锟轿帮拷锟 523 + // 如果当前点为前景
524 if (count < model->nMatch) 524 if (count < model->nMatch)
525 { 525 {
526 output[y * model->width + x] = VBPARAM->DEFAULT_COLOR_FOREGROUND; 526 output[y * model->width + x] = VBPARAM->DEFAULT_COLOR_FOREGROUND;
527 527
528 - // 前20帧锟斤拷锟斤拷模锟斤拷锟斤拷 528 + // 前20帧增加模板信
529 if (g_frameCount < model->nSample) 529 if (g_frameCount < model->nSample)
530 { 530 {
531 - // 锟斤拷锟斤拷锟斤拷碌锟角帮拷锟斤拷应锟斤拷模锟斤拷锟叫碉拷某一锟斤拷锟斤拷 531 + // 随机更新当前点对应的模板中的某一背景
532 rand = GetRand() % (model->nSample); 532 rand = GetRand() % (model->nSample);
533 tmpValue = sampleOffset + ((rand << 1) +rand ); 533 tmpValue = sampleOffset + ((rand << 1) +rand );
534 model->bg_samples[tmpValue] = image[imageOffset]; 534 model->bg_samples[tmpValue] = image[imageOffset];
535 model->bg_samples[tmpValue + 1] = image[imageOffset + 1]; 535 model->bg_samples[tmpValue + 1] = image[imageOffset + 1];
536 model->bg_samples[tmpValue + 2] = image[imageOffset + 2]; 536 model->bg_samples[tmpValue + 2] = image[imageOffset + 2];
537 537
538 - // 同时锟斤拷锟斤拷缘锟角帮拷锟斤拷某一锟斤拷锟斤拷锟节碉拷锟接︼拷锟侥o拷锟斤拷械锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟叫革拷锟斤拷 538 + // 同时随机对当前点的某一个相邻点对应的模板中的随机一背景进行更新
539 GetRandNeighborXY(x, y, &xNG, &yNG); 539 GetRandNeighborXY(x, y, &xNG, &yNG);
540 rand = GetRand() % (model->nSample); 540 rand = GetRand() % (model->nSample);
541 tmpValue = ((yNG * model->width * model->nSample + xNG * model->nSample + rand) << 1)+ (yNG * model->width * model->nSample + xNG * model->nSample + rand); 541 tmpValue = ((yNG * model->width * model->nSample + xNG * model->nSample + rand) << 1)+ (yNG * model->width * model->nSample + xNG * model->nSample + rand);
@@ -545,12 +545,12 @@ void RegionSurveillance::VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, u @@ -545,12 +545,12 @@ void RegionSurveillance::VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, u
545 } 545 }
546 } 546 }
547 547
548 - // 锟斤拷锟斤拷锟角帮拷锟轿拷锟斤拷锟 548 + // 如果当前点为背景
549 else 549 else
550 { 550 {
551 output[y * model->width + x] = VBPARAM->DEFAULT_COLOR_BACKGROUND; 551 output[y * model->width + x] = VBPARAM->DEFAULT_COLOR_BACKGROUND;
552 552
553 - // 锟斤拷前20帧锟斤拷锟斤拷VIBE模锟斤拷锟斤拷拢锟酵帮拷锟斤拷锟 553 + // 对前20帧进行VIBE模板更新(同前景)
554 if (g_frameCount < model->nSample) 554 if (g_frameCount < model->nSample)
555 { 555 {
556 //curr 556 //curr
@@ -582,7 +582,7 @@ void RegionSurveillance::VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, u @@ -582,7 +582,7 @@ void RegionSurveillance::VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, u
582 } 582 }
583 583
584 //update neighboring pixel model 584 //update neighboring pixel model
585 - // 锟斤拷锟斤拷锟斤拷锟斤拷锟脚斤拷锟叫憋拷锟斤拷锟斤拷锟铰o拷为锟斤拷锟斤拷锟劫o拷 585 + // 满足条件才进行背景更新(为了提速)
586 rand = GetRand() % (model->upSpeed); 586 rand = GetRand() % (model->upSpeed);
587 if (rand == 0 && left_flag == 1) 587 if (rand == 0 && left_flag == 1)
588 { 588 {
@@ -606,11 +606,11 @@ void RegionSurveillance::VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, u @@ -606,11 +606,11 @@ void RegionSurveillance::VibeModelUpdateC3(VibeModel_t *model, uint8_t *image, u
606 }// end of for y loop 606 }// end of for y loop
607 607
608 608
609 - //VibeModelDilation(output, model->width, model->height); // 锟斤拷锟斤拷  
610 - //VibeModelErosion(output, model->width, model->height);// 锟斤拷蚀 609 + //VibeModelDilation(output, model->width, model->height); // 膨胀
  610 + //VibeModelErosion(output, model->width, model->height);// 腐蚀
611 611
612 - VibeModelDilation2(output, maskImg, model->width, model->height); // 锟斤拷锟斤拷 锟斤拷锟斤拷  
613 - VibeModelErosion2(maskImg, output, model->width, model->height); // 锟斤拷锟斤拷 锟斤拷锟斤拷 612 + VibeModelDilation2(output, maskImg, model->width, model->height); // 加速 膨胀
  613 + VibeModelErosion2(maskImg, output, model->width, model->height); // 加速 膨胀
614 614
615 //VibeModelErosion(output,model->width,model->height); 615 //VibeModelErosion(output,model->width,model->height);
616 616
@@ -629,11 +629,11 @@ void RegionSurveillance::RSDetect(unsigned char* frameImgData, RegionInfo* pRegi @@ -629,11 +629,11 @@ void RegionSurveillance::RSDetect(unsigned char* frameImgData, RegionInfo* pRegi
629 } 629 }
630 */ 630 */
631 631
632 - // 锟斤拷玫锟角爸★拷锟角帮拷锟斤拷捅锟斤拷锟斤拷锟角帮拷锟55 锟斤拷锟斤拷0锟斤拷同时锟斤拷VIBE模锟斤拷锟斤拷懈锟斤拷锟 632 + // 获得当前帧的前景和背景(前景255 背景0)同时对VIBE模板进行更新
633 //VibeModelUpdateC3(vbM, frameImgData, greyImgData, MaskImgData); 633 //VibeModelUpdateC3(vbM, frameImgData, greyImgData, MaskImgData);
634 if (vbM->nChannel == 3) 634 if (vbM->nChannel == 3)
635 { 635 {
636 - // 锟斤拷斯模锟斤拷 636 + // 高斯模糊
637 if (gfiltFlag == 1) 637 if (gfiltFlag == 1)
638 { 638 {
639 unsigned char* inputData = NULL; 639 unsigned char* inputData = NULL;
@@ -671,10 +671,10 @@ void RegionSurveillance::RSDetect(unsigned char* frameImgData, RegionInfo* pRegi @@ -671,10 +671,10 @@ void RegionSurveillance::RSDetect(unsigned char* frameImgData, RegionInfo* pRegi
671 { 671 {
672 if (channel_num == 3) 672 if (channel_num == 3)
673 { 673 {
674 - // 锟斤拷RGB图锟斤拷转锟斤拷为锟揭讹拷图锟斤拷 674 + // 将RGB图像转换为灰度图像
675 VibeRGBToGray(frameImgData, greyImgData); 675 VibeRGBToGray(frameImgData, greyImgData);
676 676
677 - // 锟斤拷斯模锟斤拷 677 + // 高斯模糊
678 if (gfiltFlag == 1) 678 if (gfiltFlag == 1)
679 { 679 {
680 unsigned char* inputData = NULL; 680 unsigned char* inputData = NULL;
@@ -705,7 +705,7 @@ void RegionSurveillance::RSDetect(unsigned char* frameImgData, RegionInfo* pRegi @@ -705,7 +705,7 @@ void RegionSurveillance::RSDetect(unsigned char* frameImgData, RegionInfo* pRegi
705 } 705 }
706 else 706 else
707 { 707 {
708 - // 锟斤拷斯模锟斤拷 708 + // 高斯模糊
709 if (gfiltFlag == 1) 709 if (gfiltFlag == 1)
710 { 710 {
711 unsigned char* inputData = NULL; 711 unsigned char* inputData = NULL;
@@ -739,7 +739,7 @@ void RegionSurveillance::RSDetect(unsigned char* frameImgData, RegionInfo* pRegi @@ -739,7 +739,7 @@ void RegionSurveillance::RSDetect(unsigned char* frameImgData, RegionInfo* pRegi
739 739
740 740
741 /* 741 /*
742 - // 锟斤拷示锟斤拷值图锟斤拷 742 + // 显示二值图像
743 CvSize a; 743 CvSize a;
744 a.width = GlobelWidth; 744 a.width = GlobelWidth;
745 a.height = GlobelHeight; 745 a.height = GlobelHeight;
@@ -756,12 +756,12 @@ void RegionSurveillance::RSDetect(unsigned char* frameImgData, RegionInfo* pRegi @@ -756,12 +756,12 @@ void RegionSurveillance::RSDetect(unsigned char* frameImgData, RegionInfo* pRegi
756 756
757 /****************************************************************************** 757 /******************************************************************************
758 * Function: VibeModelDilation 758 * Function: VibeModelDilation
759 -* Description: VIBE模锟斤拷锟斤拷锟酵o拷锟斤拷锟斤拷锟角帮拷锟轿帮拷锟斤拷锟斤拷叩锟角帮拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷一锟斤拷为前锟斤拷锟斤拷锟斤拷前锟斤拷位前锟斤拷锟斤拷 759 +* Description: VIBE模型膨胀(如果当前点为前景或者当前点的邻域中有一个为前景,则当前点位前景)
760 * Called By: VibeModelUpdateC3 760 * Called By: VibeModelUpdateC3
761 -* Input: inputdata 锟斤拷前图锟斤拷前锟斤拷锟斤拷锟斤拷锟斤拷前锟斤拷为255 锟斤拷锟斤拷为0锟斤拷  
762 - width 图锟斤拷锟斤拷锟  
763 - height 图锟斤拷叨锟  
764 -* Output: inputdata 锟斤拷锟酵猴拷前图锟斤拷前锟斤拷锟斤拷锟斤拷 761 +* Input: inputdata 当前图像前景背景(前景为255 背景为0)
  762 + width 图像宽度
  763 + height 图像高度
  764 +* Output: inputdata 膨胀后当前图像前景背景
765 *******************************************************************************/ 765 *******************************************************************************/
766 void RegionSurveillance::VibeModelDilation(unsigned char* inputdata, int width, int height) 766 void RegionSurveillance::VibeModelDilation(unsigned char* inputdata, int width, int height)
767 { 767 {
@@ -805,12 +805,12 @@ void RegionSurveillance::VibeModelDilation(unsigned char* inputdata, int width, @@ -805,12 +805,12 @@ void RegionSurveillance::VibeModelDilation(unsigned char* inputdata, int width,
805 805
806 /****************************************************************************** 806 /******************************************************************************
807 * Function: VibeModelErosion 807 * Function: VibeModelErosion
808 -* Description: VIBE模锟酵革拷蚀锟斤拷锟斤拷锟斤拷锟角帮拷锟斤拷前锟斤拷锟侥骋伙拷锟斤拷锟斤拷锟斤拷锟斤拷锟揭伙拷锟斤拷锟轿拷锟斤拷锟斤拷锟斤拷锟角拔拷锟斤拷锟斤拷锟 808 +* Description: VIBE模型腐蚀(如果当前点或当前点的某一个邻域中有一个点为背景,则当前为背景)
809 * Called By: VibeModelUpdateC3 809 * Called By: VibeModelUpdateC3
810 -* Input: inputdata 锟斤拷前图锟斤拷前锟斤拷锟斤拷锟斤拷锟斤拷前锟斤拷为255 锟斤拷锟斤拷为0锟斤拷  
811 - width 图锟斤拷锟斤拷锟  
812 - height 图锟斤拷叨锟  
813 -* Output: inputdata 锟斤拷蚀锟斤拷前图锟斤拷前锟斤拷锟斤拷锟斤拷 810 +* Input: inputdata 当前图像前景背景(前景为255 背景为0)
  811 + width 图像宽度
  812 + height 图像高度
  813 +* Output: inputdata 腐蚀后当前图像前景背景
814 *******************************************************************************/ 814 *******************************************************************************/
815 void RegionSurveillance::VibeModelErosion(unsigned char* inputdata, int width, int height) 815 void RegionSurveillance::VibeModelErosion(unsigned char* inputdata, int width, int height)
816 { 816 {
@@ -871,7 +871,7 @@ typedef struct _int_128 @@ -871,7 +871,7 @@ typedef struct _int_128
871 871
872 const _int_128 & int_128_max(const _int_128 & n1, const _int_128 & n2) 872 const _int_128 & int_128_max(const _int_128 & n1, const _int_128 & n2)
873 { 873 {
874 - if (platform_little_endian) //小锟斤拷 874 + if (platform_little_endian) //С??
875 { 875 {
876 if (n1._n2 > n2._n2) 876 if (n1._n2 > n2._n2)
877 { 877 {
@@ -899,7 +899,7 @@ const _int_128 &amp; int_128_max(const _int_128 &amp; n1, const _int_128 &amp; n2) @@ -899,7 +899,7 @@ const _int_128 &amp; int_128_max(const _int_128 &amp; n1, const _int_128 &amp; n2)
899 } 899 }
900 else 900 else
901 { 901 {
902 - if (n1._n1 > n2._n1) //锟斤拷锟 902 + if (n1._n1 > n2._n1) //???
903 { 903 {
904 return n1; 904 return n1;
905 } 905 }
@@ -933,21 +933,21 @@ void int_128_store(_int_128 * n1, _int_128 &amp; n2) @@ -933,21 +933,21 @@ void int_128_store(_int_128 * n1, _int_128 &amp; n2)
933 void RegionSurveillance::VibeModelDilation2(unsigned char* inputdata, unsigned char *output, int width, int height) 933 void RegionSurveillance::VibeModelDilation2(unsigned char* inputdata, unsigned char *output, int width, int height)
934 { 934 {
935 memset(output, 0, sizeof(output[0])*width*height); 935 memset(output, 0, sizeof(output[0])*width*height);
936 - if (width<32 || height<32 || inputdata == NULL || output == NULL) 936 + if (width<32 || height<32 || inputdata==NULL || output==NULL)
937 return; 937 return;
938 unsigned char *src = inputdata; 938 unsigned char *src = inputdata;
939 unsigned char *dst = output; 939 unsigned char *dst = output;
940 940
941 //memcpy(output, inputdata, width*height); 941 //memcpy(output, inputdata, width*height);
942 - for (int i = 0; i<height; i++) {  
943 - output[i*width + 0] = 0;  
944 - output[i*width + width - 1] = 0; 942 + for (int i=0; i<height; i++) {
  943 + output[i*width+0] = 0;
  944 + output[i*width+width-1] = 0;
945 } 945 }
946 - for (int j = 0; j<width; j++) { 946 + for (int j=0; j<width; j++) {
947 output[j] = 0; 947 output[j] = 0;
948 - output[(height - 1)*width + j] = 0; 948 + output[(height-1)*width+j]=0;
949 } 949 }
950 - for (int i = 1; i<height - 1; i++) 950 + for (int i=1; i<height-1; i++)
951 { 951 {
952 src = inputdata + i*width; 952 src = inputdata + i*width;
953 dst = output + i*width; 953 dst = output + i*width;
@@ -972,24 +972,24 @@ void RegionSurveillance::VibeModelDilation2(unsigned char* inputdata, unsigned c @@ -972,24 +972,24 @@ void RegionSurveillance::VibeModelDilation2(unsigned char* inputdata, unsigned c
972 } 972 }
973 973
974 } 974 }
975 -void RegionSurveillance::VibeModelErosion2(unsigned char* inputdata, unsigned char *output, int width, int height) 975 +void RegionSurveillance::VibeModelErosion2(unsigned char* inputdata,unsigned char *output, int width,int height)
976 { 976 {
977 memset(output, 0, sizeof(output[0])*width*height); 977 memset(output, 0, sizeof(output[0])*width*height);
978 - if (width<32 || height<32 || inputdata == NULL || output == NULL) 978 + if (width<32 || height<32 || inputdata==NULL || output==NULL)
979 return; 979 return;
980 unsigned char *src = inputdata; 980 unsigned char *src = inputdata;
981 unsigned char *dst = output; 981 unsigned char *dst = output;
982 982
983 //memcpy(output, inputdata, width*height); 983 //memcpy(output, inputdata, width*height);
984 - for (int i = 0; i<height; i++) {  
985 - output[i*width + 0] = 0;  
986 - output[i*width + width - 1] = 0; 984 + for (int i=0; i<height; i++) {
  985 + output[i*width+0] = 0;
  986 + output[i*width+width-1] = 0;
987 } 987 }
988 - for (int j = 0; j<width; j++) { 988 + for (int j=0; j<width; j++) {
989 output[j] = 0; 989 output[j] = 0;
990 - output[(height - 1)*width + j] = 0; 990 + output[(height-1)*width+j]=0;
991 } 991 }
992 - for (int i = 1; i<height-1; i++) 992 + for (int i=1; i<height-1; i++)
993 { 993 {
994 src = inputdata + i*width; 994 src = inputdata + i*width;
995 dst = output + i*width; 995 dst = output + i*width;
@@ -1014,93 +1014,9 @@ void RegionSurveillance::VibeModelErosion2(unsigned char* inputdata, unsigned ch @@ -1014,93 +1014,9 @@ void RegionSurveillance::VibeModelErosion2(unsigned char* inputdata, unsigned ch
1014 } 1014 }
1015 1015
1016 } 1016 }
1017 -//void RegionSurveillance::VibeModelDilation2(unsigned char* inputdata,unsigned char *output, int width,int height)  
1018 -//{  
1019 -// memset(output, 0, sizeof(output[0])*width*height);  
1020 -// if (width<32 || height<32 || inputdata==NULL || output==NULL)  
1021 -// return;  
1022 -// unsigned char *src = inputdata;  
1023 -// unsigned char *dst = output;  
1024 -//  
1025 -// //memcpy(output, inputdata, width*height);  
1026 -// for (int i=0; i<height; i++) {  
1027 -// output[i*width+0] = 0;  
1028 -// output[i*width+width-1] = 0;  
1029 -// }  
1030 -// for (int j=0; j<width; j++) {  
1031 -// output[j] = 0;  
1032 -// output[(height-1)*width+j]=0;  
1033 -// }  
1034 -// for (int i=1; i<height-1; i++)  
1035 -// {  
1036 -// src = inputdata + i*width;  
1037 -// dst = output + i*width;  
1038 -// for (int j = 1; j < width - 16; j += 16)  
1039 -// {  
1040 -// // 2 unaligned loads.  
1041 -// __m128i m = _mm_loadu_si128((const __m128i*)(src + j ));  
1042 -// m = _mm_max_epu8(m, _mm_loadu_si128((const __m128i*)(src + j - 1 - width)));  
1043 -// m = _mm_max_epu8(m, _mm_loadu_si128((const __m128i*)(src + j + 1)));  
1044 -// m = _mm_max_epu8(m, _mm_loadu_si128((const __m128i*)(src + j - width)));  
1045 -// m = _mm_max_epu8(m, _mm_loadu_si128((const __m128i*)(src + j + 1 - width)));  
1046 -//  
1047 -// // 3 aligned loads: more efficient.  
1048 -// m = _mm_max_epu8(m, _mm_loadu_si128((const __m128i*)(src + j -1)));  
1049 -//  
1050 -// m = _mm_max_epu8(m, _mm_loadu_si128((const __m128i*)(src + j + width)));  
1051 -// m = _mm_max_epu8(m, _mm_loadu_si128((const __m128i*)(src + j -1 + width)));  
1052 -// m = _mm_max_epu8(m, _mm_loadu_si128((const __m128i*)(src + j +1 + width)));  
1053 -// // Store the result in the destination image.  
1054 -// _mm_storeu_si128((__m128i*)(dst + j), m);  
1055 -// }  
1056 -// }  
1057 -//  
1058 -//}  
1059 -//void RegionSurveillance::VibeModelErosion2(unsigned char* inputdata,unsigned char *output, int width,int height)  
1060 -//{  
1061 -// memset(output, 0, sizeof(output[0])*width*height);  
1062 -// if (width<32 || height<32 || inputdata==NULL || output==NULL)  
1063 -// return;  
1064 -// unsigned char *src = inputdata;  
1065 -// unsigned char *dst = output;  
1066 -//  
1067 -// //memcpy(output, inputdata, width*height);  
1068 -// for (int i=0; i<height; i++) {  
1069 -// output[i*width+0] = 0;  
1070 -// output[i*width+width-1] = 0;  
1071 -// }  
1072 -// for (int j=0; j<width; j++) {  
1073 -// output[j] = 0;  
1074 -// output[(height-1)*width+j]=0;  
1075 -// }  
1076 -// for (int i=1; i<height-1; i++)  
1077 -// {  
1078 -// src = inputdata + i*width;  
1079 -// dst = output + i*width;  
1080 -// for (int j = 1; j < width - 16; j += 16)  
1081 -// {  
1082 -// // 2 unaligned loads.  
1083 -// __m128i m = _mm_loadu_si128((const __m128i*)(src + j ));  
1084 -// m = _mm_min_epu8(m, _mm_loadu_si128((const __m128i*)(src + j - 1 - width)));  
1085 -// m = _mm_min_epu8(m, _mm_loadu_si128((const __m128i*)(src + j + 1)));  
1086 -// m = _mm_min_epu8(m, _mm_loadu_si128((const __m128i*)(src + j - width)));  
1087 -// m = _mm_min_epu8(m, _mm_loadu_si128((const __m128i*)(src + j + 1 - width)));  
1088 -//  
1089 -// // 3 aligned loads: more efficient.  
1090 -// m = _mm_min_epu8(m, _mm_loadu_si128((const __m128i*)(src + j -1)));  
1091 -//  
1092 -// m = _mm_min_epu8(m, _mm_loadu_si128((const __m128i*)(src + j + width)));  
1093 -// m = _mm_min_epu8(m, _mm_loadu_si128((const __m128i*)(src + j -1 + width)));  
1094 -// m = _mm_min_epu8(m, _mm_loadu_si128((const __m128i*)(src + j +1 + width)));  
1095 -// // Store the result in the destination image.  
1096 -// _mm_storeu_si128((__m128i*)(dst + j), m);  
1097 -// }  
1098 -// }  
1099 -//  
1100 -//}  
1101 1017
1102 1018
1103 -//锟斤拷锟斤拷锟斤拷锟侥碉拷锟轿伙拷媒锟斤拷锟斤拷锟斤拷锟 by zl 1019 +//按照中心点的位置进行排序 by zl
1104 void RegionSurveillance::SortForeground(vector<CForeground> &ForegroundArray) 1020 void RegionSurveillance::SortForeground(vector<CForeground> &ForegroundArray)
1105 { 1021 {
1106 std::sort(ForegroundArray.begin(),ForegroundArray.end(), SortByPoint); 1022 std::sort(ForegroundArray.begin(),ForegroundArray.end(), SortByPoint);
@@ -1111,30 +1027,30 @@ int RegionSurveillance::dwGlobalID; @@ -1111,30 +1027,30 @@ int RegionSurveillance::dwGlobalID;
1111 /****************************************************************************** 1027 /******************************************************************************
1112 * Function: VibeModelGetTrace 1028 * Function: VibeModelGetTrace
1113 * Description: 1029 * Description:
1114 -* Calls锟斤拷 ExtractContours 1030 +* Calls ExtractContours
1115 * Called By: RSDetect 1031 * Called By: RSDetect
1116 -* Input: pSourceImg 锟斤拷前图锟斤拷前锟斤拷锟斤拷锟斤拷锟斤拷前锟斤拷为255 锟斤拷锟斤拷为0锟斤拷  
1117 - pRGBIn 锟斤拷前图锟斤拷RGB  
1118 - width 图锟斤拷锟斤拷锟  
1119 - height 图锟斤拷叨锟  
1120 - widthStep 图锟斤拷RGB step  
1121 -* Output: pRGBIn 锟斤拷前锟斤拷锟斤拷锟斤拷锟斤拷RGB 1032 +* Input: pSourceImg 当前图像前景背景(前景为255 背景为0)
  1033 + pRGBIn 当前图像RGB
  1034 + width 图像宽度
  1035 + height 图像高度
  1036 + widthStep 图像RGB step
  1037 +* Output: pRGBIn 将前景描绘过的RGB
1122 m_TargetArray 1038 m_TargetArray
1123 - m_ptArray 锟诫当前目锟斤拷匹锟斤拷晒锟斤拷锟斤拷锟斤拷锟角帮拷锟斤拷锟斤拷锟斤拷牡锟  
1124 - m_VectorDirection 锟斤拷前目锟斤拷锟斤拷之前目锟斤拷锟斤拷锟斤拷锟 1039 + m_ptArray 与当前目标匹配成功的所有前景的中心点
  1040 + m_VectorDirection 当前目标与之前目标的向量
1125 //m_VectorDirectionNormal dx/sqrt(dx^2+dy^2) dy/sqrt(dx^2+dy^2) 1041 //m_VectorDirectionNormal dx/sqrt(dx^2+dy^2) dy/sqrt(dx^2+dy^2)
1126 - m_CurRefPoint 目锟斤拷锟斤拷锟斤拷牡锟轿伙拷茫锟斤拷锟斤拷细锟斤拷拢锟饺拷锟斤拷锟狡斤拷锟街碉拷锟  
1127 - m_LastRefPoint 目锟斤拷之前锟斤拷锟斤拷锟侥碉拷位锟矫o拷锟斤拷锟较革拷锟铰o拷取5锟斤拷锟斤拷平锟斤拷值锟斤拷  
1128 - m_PredictionBasePoint 锟斤拷锟揭伙拷锟狡ワ拷锟斤拷锟斤拷锟斤拷位锟斤拷  
1129 - m_PredictionPoint 锟斤拷一帧锟斤拷预锟斤拷位锟斤拷  
1130 - m_bHaveDirection 锟斤拷前目锟斤拷锟角凤拷锟窖撅拷锟斤拷锟斤拷锟斤拷锟斤拷锟 true锟斤拷 flase锟斤拷  
1131 - m_dwLostFrame 锟洁当前帧未匹锟戒到锟斤拷锟斤拷目锟斤拷锟斤拷锟斤拷锟叫讹拷锟角凤拷目锟疥丢失锟斤拷  
1132 - m_dwID ID 锟斤拷锟斤拷锟皆诧拷同锟斤拷前锟斤拷锟斤拷图时锟斤拷锟斤拷锟斤拷色锟较碉拷锟斤拷锟斤拷  
1133 - m_dwBestMatch 匹锟戒到锟斤拷前帧锟斤拷前锟斤拷锟斤拷锟  
1134 - m_bCalc 锟斤拷志目锟斤拷锟斤拷锟斤拷锟节碉拷前帧锟斤拷锟角凤拷匹锟戒到 true匹锟戒到 false未匹锟戒到  
1135 - m_AlarmState 锟斤拷锟斤拷状态 false锟斤拷 true锟斤拷锟斤拷  
1136 - m_AlarmNum 锟斤拷锟斤拷锟斤拷锟  
1137 - //m_TarBox 目锟斤拷锟斤拷锟接撅拷锟斤拷 1042 + m_CurRefPoint 目标的中心点位置(不断更新,取5个的平均值)
  1043 + m_LastRefPoint 目标之前的中心点位置(不断更新,取5个的平均值)
  1044 + m_PredictionBasePoint 最后一个匹配点中心位置
  1045 + m_PredictionPoint 下一帧的预测位置
  1046 + m_bHaveDirection 当前目标是否已经计算过方向 true是 flase否
  1047 + m_dwLostFrame 距当前帧未匹配到的数目(用来判断是否目标丢失)
  1048 + m_dwID ID 用来对不同的前景绘图时进行颜色上的区分
  1049 + m_dwBestMatch 匹配到当前帧的前景序号
  1050 + m_bCalc 标志目标序列在当前帧中是否匹配到 true匹配到 false未匹配到
  1051 + m_AlarmState 报警状态 false否 true报警
  1052 + m_AlarmNum 报警编号
  1053 + //m_TarBox 目标的外接矩形
1138 *******************************************************************************/ 1054 *******************************************************************************/
1139 void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *MaskImgCfd, unsigned char* pRGBIn, RegionInfo* pRegionInfo) 1055 void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *MaskImgCfd, unsigned char* pRGBIn, RegionInfo* pRegionInfo)
1140 { 1056 {
@@ -1150,13 +1066,13 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1150,13 +1066,13 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1150 int m_dwMaxLost = 100; 1066 int m_dwMaxLost = 100;
1151 int m_dwMinFrame = 6; 1067 int m_dwMinFrame = 6;
1152 int dwTargetSize = 0; 1068 int dwTargetSize = 0;
1153 - CForeground testTarget; // testForgroundArray 锟叫碉拷testTarget 1069 + CForeground testTarget; // testForgroundArray 中的testTarget
1154 1070
1155 - //前锟斤拷图锟斤拷锟斤拷-zhm 1071 + //前景图集合-zhm
1156 vector<CContour> foreContours; 1072 vector<CContour> foreContours;
1157 CConExtraction *pConExtraction = new CConExtraction(); 1073 CConExtraction *pConExtraction = new CConExtraction();
1158 1074
1159 - // 锟斤拷锟斤拷锟斤拷锟斤拷锟侥o拷锟斤拷锟截碉拷 锟斤拷锟斤拷锟斤拷锟斤拷锟00锟斤拷前锟斤拷锟斤拷泳锟斤拷锟 1075 + // 满足条件的(像素点 面积等条件100)前景外接矩形
1160 if (channel_num == 3) 1076 if (channel_num == 3)
1161 { 1077 {
1162 foreContours = pConExtraction->ExtractContours(pSourceImg, MaskImgCfd,GlobelWidth, GlobelHeight, GlobelWidthstep / 3); 1078 foreContours = pConExtraction->ExtractContours(pSourceImg, MaskImgCfd,GlobelWidth, GlobelHeight, GlobelWidthstep / 3);
@@ -1166,8 +1082,8 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1166,8 +1082,8 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1166 foreContours = pConExtraction->ExtractContours(pSourceImg, MaskImgCfd, GlobelWidth, GlobelHeight, GlobelWidthstep); 1082 foreContours = pConExtraction->ExtractContours(pSourceImg, MaskImgCfd, GlobelWidth, GlobelHeight, GlobelWidthstep);
1167 } 1083 }
1168 1084
1169 - //锟届迹匹锟斤拷-zhm  
1170 - // 锟斤拷一锟斤拷锟斤拷foreContours锟侥伙拷锟斤拷锟较讹拷前锟斤拷锟斤拷泳锟斤拷蔚锟斤拷锟斤拷锟斤拷锟斤拷筛选 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟00锟斤拷锟斤拷泳锟斤拷锟斤拷锟斤拷锟紽oregroundArray锟斤拷 1085 + //轨迹匹配-zhm
  1086 + // 进一步在foreContours的基础上对前景外接矩形的面积进行筛选 将满足面积大于300的外接矩形添入ForegroundArray中
1171 int forNum = foreContours.size(); 1087 int forNum = foreContours.size();
1172 for (int i = 0; i < forNum; i++) 1088 for (int i = 0; i < forNum; i++)
1173 { 1089 {
@@ -1180,7 +1096,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1180,7 +1096,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1180 testTarget.m_ptCenter.y = (testTarget.m_rtConnect.top + testTarget.m_rtConnect.bottom) / 2; 1096 testTarget.m_ptCenter.y = (testTarget.m_rtConnect.top + testTarget.m_rtConnect.bottom) / 2;
1181 testTarget.m_cfd = foreContours[i].cfd; 1097 testTarget.m_cfd = foreContours[i].cfd;
1182 1098
1183 - //锟斤拷锟斤拷锟斤拷小锟斤拷锟斤拷锟斤拷锟斤拷锟叫★拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 by zl 20160304 1099 + //??????С?????????С??????????? by zl 20160304
1184 int targetArea = abs((testTarget.m_rtConnect.left - testTarget.m_rtConnect.right) * (testTarget.m_rtConnect.top - testTarget.m_rtConnect.bottom)); 1100 int targetArea = abs((testTarget.m_rtConnect.left - testTarget.m_rtConnect.right) * (testTarget.m_rtConnect.top - testTarget.m_rtConnect.bottom));
1185 if ( targetArea > OBJECT_AREA_MIN && targetArea < OBJECT_AREA_MAX) 1101 if ( targetArea > OBJECT_AREA_MIN && targetArea < OBJECT_AREA_MAX)
1186 { 1102 {
@@ -1189,7 +1105,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1189,7 +1105,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1189 1105
1190 1106
1191 } 1107 }
1192 - if(ForegroundArray.size() > 0) //前锟斤拷锟解不锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 by zl 20160307 1108 + if(ForegroundArray.size() > 0) //前景库不空则排序处理 by zl 20160307
1193 { 1109 {
1194 SortForeground(ForegroundArray); 1110 SortForeground(ForegroundArray);
1195 MergeNeighborBox(ForegroundArray); 1111 MergeNeighborBox(ForegroundArray);
@@ -1208,14 +1124,14 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1208,14 +1124,14 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1208 delete pConExtraction; 1124 delete pConExtraction;
1209 // memory leak for 1 block 1125 // memory leak for 1 block
1210 m_DelArray.clear(); 1126 m_DelArray.clear();
1211 - //锟叫讹拷锟角凤拷帧锟斤拷目锟疥丢失锟斤拷锟斤拷锟斤拷失dwTargetSize锟皆硷拷 1127 + //判断是否帧内目标丢失,若丢失dwTargetSize自减
1212 vector<CTarget>::size_type countn = 0; 1128 vector<CTarget>::size_type countn = 0;
1213 int dwStep = GlobelWidthstep; 1129 int dwStep = GlobelWidthstep;
1214 ///////////////////////////////////////////////////////////////////////////////////////// 1130 /////////////////////////////////////////////////////////////////////////////////////////
1215 dwTargetSize = m_TargetArray.size(); 1131 dwTargetSize = m_TargetArray.size();
1216 for (int i = 0; i < dwTargetSize; i++, countn++) 1132 for (int i = 0; i < dwTargetSize; i++, countn++)
1217 { 1133 {
1218 - // 锟斤拷锟窖撅拷锟斤拷锟斤拷100帧未锟斤拷锟街革拷前锟斤拷 锟津将革拷前锟斤拷锟斤拷m_TargetArray锟斤拷删锟斤拷 1134 + // 若已经超过100帧未出现该前景 则将该前景从m_TargetArray中删除
1219 if (m_TargetArray[i].m_dwLostFrame++ > m_dwMaxLost) 1135 if (m_TargetArray[i].m_dwLostFrame++ > m_dwMaxLost)
1220 { 1136 {
1221 m_DelArray.push_back(*(m_TargetArray.begin() + countn)); 1137 m_DelArray.push_back(*(m_TargetArray.begin() + countn));
@@ -1247,7 +1163,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1247,7 +1163,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1247 dwTargetSize = m_TargetArray.size(); 1163 dwTargetSize = m_TargetArray.size();
1248 double * pDistanceMatrix = new double[dwForegroundCount * dwTargetSize]; 1164 double * pDistanceMatrix = new double[dwForegroundCount * dwTargetSize];
1249 1165
1250 - // 锟斤拷每一锟斤拷目锟斤拷透锟街★拷械锟角帮拷锟斤拷锟斤拷锟狡ワ拷锟 1166 + // 将每一个目标和该帧中的前景进行匹配
1251 for (int i = 0; i < dwTargetSize; i++) 1167 for (int i = 0; i < dwTargetSize; i++)
1252 { 1168 {
1253 //CMPointDouble directionPre; 1169 //CMPointDouble directionPre;
@@ -1279,7 +1195,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1279,7 +1195,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1279 m_FinalArray.clear(); 1195 m_FinalArray.clear();
1280 //m_TargetArray.clear(); 1196 //m_TargetArray.clear();
1281 // Tracking and draw 1197 // Tracking and draw
1282 - // 锟皆碉拷前帧锟斤拷每一锟斤拷前锟斤拷锟斤拷目锟斤拷锟斤拷锟狡ワ拷锟 1198 + // 对当前帧的每一个前景与目标进行匹配
1283 bool left_flag_c = 1; 1199 bool left_flag_c = 1;
1284 for (int i = 0; i < dwForegroundCount; i++) 1200 for (int i = 0; i < dwForegroundCount; i++)
1285 { 1201 {
@@ -1307,7 +1223,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1307,7 +1223,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1307 } 1223 }
1308 } 1224 }
1309 //m_TargetArray.clear(); 1225 //m_TargetArray.clear();
1310 - // 锟斤拷锟狡ワ拷锟缴癸拷 m_TargetArray[dwBestMatch].m_ptArray.size() !=500锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷为什么锟斤拷锟杰碉拷锟斤拷500 1226 + // 如果匹配成功 m_TargetArray[dwBestMatch].m_ptArray.size() !=500??????????????????????不理解为什么不能等于500
1311 if (dwBestMatch >= 0 && m_TargetArray[dwBestMatch].m_dwBestMatch == i && m_TargetArray[dwBestMatch].m_ptArray.size() < 500) 1227 if (dwBestMatch >= 0 && m_TargetArray[dwBestMatch].m_dwBestMatch == i && m_TargetArray[dwBestMatch].m_ptArray.size() < 500)
1312 { 1228 {
1313 // Find it 1229 // Find it
@@ -1335,10 +1251,10 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1335,10 +1251,10 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1335 } 1251 }
1336 1252
1337 // Update last reference point 1253 // Update last reference point
1338 - // 锟斤拷锟斤拷锟侥匡拷锟狡ワ拷锟缴癸拷锟斤拷前锟斤拷锟斤到一锟斤拷锟斤拷锟斤拷 1254 + // 如果与目标匹配成功的前景达到一定数量
1339 if (dwPointCount > m_dwFrameDist) 1255 if (dwPointCount > m_dwFrameDist)
1340 { 1256 {
1341 - // 目锟斤拷之前锟斤拷锟斤拷锟侥碉拷位锟矫o拷5帧帧平锟斤拷锟斤拷 1257 + // 目标之前的中心点位置(5帧帧平均)
1342 m_TargetArray[dwBestMatch].m_LastRefPoint.x += 1258 m_TargetArray[dwBestMatch].m_LastRefPoint.x +=
1343 (double) m_TargetArray[dwBestMatch].m_ptArray[dwPointCount - m_dwFrameDist - 1].x / m_dwFrameWnd; 1259 (double) m_TargetArray[dwBestMatch].m_ptArray[dwPointCount - m_dwFrameDist - 1].x / m_dwFrameWnd;
1344 m_TargetArray[dwBestMatch].m_LastRefPoint.y += 1260 m_TargetArray[dwBestMatch].m_LastRefPoint.y +=
@@ -1371,13 +1287,13 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1371,13 +1287,13 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1371 } 1287 }
1372 else 1288 else
1373 { 1289 {
1374 - // 锟斤拷獾斤拷碌锟侥匡拷锟 1290 + // 检测到新的目标
1375 // New object found 1291 // New object found
1376 CTarget NewTarget; 1292 CTarget NewTarget;
1377 //NewTarget.GetID(); 1293 //NewTarget.GetID();
1378 NewTarget.m_dwID= ++dwGlobalID; // GlobalID assigned for target 1294 NewTarget.m_dwID= ++dwGlobalID; // GlobalID assigned for target
1379 1295
1380 - // 锟铰碉拷前锟斤拷锟斤拷锟斤拷锟斤拷位锟斤拷 1296 + // 新的前景的中心位置
1381 NewTarget.m_ptArray.push_back(ForegroundArray[i].m_ptCenter); 1297 NewTarget.m_ptArray.push_back(ForegroundArray[i].m_ptCenter);
1382 1298
1383 m_TargetArray.push_back(NewTarget); 1299 m_TargetArray.push_back(NewTarget);
@@ -1392,7 +1308,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1392,7 +1308,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1392 dwBestMatch = m_TargetArray.size() - 1; 1308 dwBestMatch = m_TargetArray.size() - 1;
1393 1309
1394 // Update current reference point 1310 // Update current reference point
1395 - //m_TargetArray-m_CurRefPoint锟斤拷前前锟斤拷锟斤拷锟斤拷锟侥碉拷位锟矫o拷取锟斤拷帧锟斤拷平锟斤拷锟斤拷锟斤拷 1311 + //m_TargetArray-m_CurRefPoint当前前景的中心点位置(取五帧的平均数)
1396 m_TargetArray[dwBestMatch].m_CurRefPoint.x += (double)ForegroundArray[i].m_ptCenter.x / m_dwFrameWnd; 1312 m_TargetArray[dwBestMatch].m_CurRefPoint.x += (double)ForegroundArray[i].m_ptCenter.x / m_dwFrameWnd;
1397 m_TargetArray[dwBestMatch].m_CurRefPoint.y += (double)ForegroundArray[i].m_ptCenter.y / m_dwFrameWnd; 1313 m_TargetArray[dwBestMatch].m_CurRefPoint.y += (double)ForegroundArray[i].m_ptCenter.y / m_dwFrameWnd;
1398 1314
@@ -1414,7 +1330,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1414,7 +1330,7 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1414 } 1330 }
1415 } 1331 }
1416 1332
1417 - //锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟侥匡拷锟 1333 + //保存最终输出目标
1418 m_FinalArray.push_back(m_TargetArray[dwBestMatch]); 1334 m_FinalArray.push_back(m_TargetArray[dwBestMatch]);
1419 /* 1335 /*
1420 // Draw it 1336 // Draw it
@@ -1427,8 +1343,8 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1427,8 +1343,8 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1427 unsigned char bBlue = (unsigned char) ((m_TargetArray[dwBestMatch].m_dwID % 13) * 20 + 15); 1343 unsigned char bBlue = (unsigned char) ((m_TargetArray[dwBestMatch].m_dwID % 13) * 20 + 15);
1428 1344
1429 // Draw rectangle 1345 // Draw rectangle
1430 - //锟斤拷锟斤拷  
1431 - // 目锟斤拷锟斤拷泳锟斤拷锟 锟斤拷色 1346 + //横线
  1347 + // 目标外接矩形 红色
1432 for (int t = ForegroundArray[i].m_rtConnect.left; t <= ForegroundArray[i].m_rtConnect.right; t++) 1348 for (int t = ForegroundArray[i].m_rtConnect.left; t <= ForegroundArray[i].m_rtConnect.right; t++)
1433 { 1349 {
1434 pRGBIn[ForegroundArray[i].m_rtConnect.top * dwStep + t * 3] = 0; 1350 pRGBIn[ForegroundArray[i].m_rtConnect.top * dwStep + t * 3] = 0;
@@ -1455,11 +1371,11 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1455,11 +1371,11 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1455 int d = ForegroundArray[i].m_rtConnect.right; 1371 int d = ForegroundArray[i].m_rtConnect.right;
1456 1372
1457 1373
1458 - // ROI 锟斤拷锟 1374 + // ROI 监控
1459 for (int ii = 0; ii < m_numROI; ii++) 1375 for (int ii = 0; ii < m_numROI; ii++)
1460 { 1376 {
1461 - // 目锟斤拷锟斤拷泳锟斤拷谓锟斤拷锟斤拷锟斤拷锟斤拷锟侥匡拷锟斤拷锟斤拷牡锟斤拷锟斤拷锟斤拷锟斤拷冢锟斤拷虮ň锟  
1462 - if (pAlarmInfo[ii] == 1) //锟斤拷止锟斤拷锟斤拷 1377 + // 目标外接矩形进行区域且目标中心点在区域内,则报警
  1378 + if (pAlarmInfo[ii] == 1) //禁止区域
1463 { 1379 {
1464 if (pRegion[ii][GlobelWidth * a + c] || 1380 if (pRegion[ii][GlobelWidth * a + c] ||
1465 pRegion[ii][GlobelWidth * b + c] || 1381 pRegion[ii][GlobelWidth * b + c] ||
@@ -1475,8 +1391,8 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1475,8 +1391,8 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1475 } 1391 }
1476 } 1392 }
1477 } 1393 }
1478 - // 只要目锟斤拷锟斤拷泳锟斤拷锟斤拷锟揭伙拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟津报撅拷  
1479 - if (pAlarmInfo[ii] == 2) //锟斤拷锟斤拷 1394 + // 只要目标外接矩形有一个点进入区域则报警
  1395 + if (pAlarmInfo[ii] == 2) //拌线
1480 { 1396 {
1481 int xmin = min(c, d), xmax = max(c, d), ymin = min(a, b), ymax = max(a, b); 1397 int xmin = min(c, d), xmax = max(c, d), ymin = min(a, b), ymax = max(a, b);
1482 for (int iy = ymin; iy <= ymax; iy++) 1398 for (int iy = ymin; iy <= ymax; iy++)
@@ -1493,8 +1409,8 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1493,8 +1409,8 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1493 } 1409 }
1494 } 1410 }
1495 1411
1496 - // 只要目锟斤拷锟斤拷泳锟斤拷谓锟斤拷锟斤拷锟斤拷锟斤拷校锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷ROI锟斤拷锟斤拷锟斤拷锟斤拷锟揭伙拷锟酵憋拷锟接撅拷锟斤拷锟斤拷锟侥碉拷锟斤拷锟斤拷锟斤拷锟节o拷锟津报撅拷  
1497 - if (pAlarmInfo[ii] == 3) //锟斤拷锟斤拷锟斤拷锟 1412 + // 只要目标外接矩形进入区域中,且面积大于ROI区域面积的一半同时外接矩形中心点在区域内,则报警
  1413 + if (pAlarmInfo[ii] == 3) //遗留检测
1498 { 1414 {
1499 int TotalArea = 0; 1415 int TotalArea = 0;
1500 if (TotalArea == 0) 1416 if (TotalArea == 0)
@@ -1522,19 +1438,19 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1522,19 +1438,19 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1522 } 1438 }
1523 } 1439 }
1524 1440
1525 - //锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟侥匡拷锟 1441 + //保存最终输出目标
1526 m_FinalArray.push_back(m_TargetArray[dwBestMatch]); 1442 m_FinalArray.push_back(m_TargetArray[dwBestMatch]);
1527 1443
1528 CMPoint ptLast = m_TargetArray[dwBestMatch].m_ptArray[0]; 1444 CMPoint ptLast = m_TargetArray[dwBestMatch].m_ptArray[0];
1529 1445
1530 - // 锟斤拷目锟斤拷锟矫恳伙拷锟狡ワ拷锟斤拷锟斤拷锟叫憋拷锟斤拷 1446 + // 对目标的每一个匹配项进行遍历
1531 for (int l = 1; l < dwPointNum; l++) 1447 for (int l = 1; l < dwPointNum; l++)
1532 { 1448 {
1533 ForegroundArray[i].m_ptCenter = m_TargetArray[dwBestMatch].m_ptArray[l]; 1449 ForegroundArray[i].m_ptCenter = m_TargetArray[dwBestMatch].m_ptArray[l];
1534 if (ForegroundArray[i].m_ptCenter == ptLast) 1450 if (ForegroundArray[i].m_ptCenter == ptLast)
1535 { 1451 {
1536 // Draw a point 1452 // Draw a point
1537 - //锟斤拷锟侥匡拷锟斤拷锟斤拷牡锟 1453 + //描绘目标中心点
1538 pRGBIn[ForegroundArray[i].m_ptCenter.y * dwStep + ForegroundArray[i].m_ptCenter.x * 3] = bBlue; 1454 pRGBIn[ForegroundArray[i].m_ptCenter.y * dwStep + ForegroundArray[i].m_ptCenter.x * 3] = bBlue;
1539 pRGBIn[ForegroundArray[i].m_ptCenter.y * dwStep + ForegroundArray[i].m_ptCenter.x * 3 + 1] = bGreen; 1455 pRGBIn[ForegroundArray[i].m_ptCenter.y * dwStep + ForegroundArray[i].m_ptCenter.x * 3 + 1] = bGreen;
1540 pRGBIn[ForegroundArray[i].m_ptCenter.y * dwStep + ForegroundArray[i].m_ptCenter.x * 3 + 2] = bRed; 1456 pRGBIn[ForegroundArray[i].m_ptCenter.y * dwStep + ForegroundArray[i].m_ptCenter.x * 3 + 2] = bRed;
@@ -1636,10 +1552,10 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1636,10 +1552,10 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1636 /////////////////////////////////////////////////////////////////////////////////////// 1552 ///////////////////////////////////////////////////////////////////////////////////////
1637 // Prediction 1553 // Prediction
1638 int dwObjectCount = m_TargetArray.size(); 1554 int dwObjectCount = m_TargetArray.size();
1639 - // 锟斤拷锟斤拷锟斤拷锟叫碉拷目锟斤拷 1555 + // 遍历所有的目标
1640 for (int i=0; i < dwObjectCount; i++) 1556 for (int i=0; i < dwObjectCount; i++)
1641 { 1557 {
1642 - // 锟斤拷锟斤拷锟侥匡拷锟斤拷诘锟角爸★拷锟矫伙拷锟狡ワ拷锟缴癸拷锟斤拷锟角碉拷前目锟斤拷锟窖撅拷锟斤拷锟斤拷锟斤拷锟斤拷锟 1558 + // 如果该目标在当前帧中没有匹配成功但是当前目标已经计算过方向
1643 if (!m_TargetArray[i].m_bCalc && m_TargetArray[i].m_bHaveDirection) 1559 if (!m_TargetArray[i].m_bCalc && m_TargetArray[i].m_bHaveDirection)
1644 { 1560 {
1645 // Record prediction as current point 1561 // Record prediction as current point
@@ -1700,15 +1616,15 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas @@ -1700,15 +1616,15 @@ void RegionSurveillance::VibeModelGetTrace(unsigned char* pSourceImg, float *Mas
1700 1616
1701 /****************************************************************************** 1617 /******************************************************************************
1702 * Function: RSRegion 1618 * Function: RSRegion
1703 -* Description: 锟斤拷锟斤拷趣锟斤拷锟斤拷锟斤拷锟斤拷 1619 +* Description: 感兴趣区域设置
1704 * Calls: vibeMask 1620 * Calls: vibeMask
1705 * Called By: main 1621 * Called By: main
1706 -* Input: numROI ROI锟斤拷锟斤拷  
1707 - pRegionInfo ROI锟斤拷锟斤拷  
1708 - iflog true:锟斤拷锟斤拷锟街 false锟斤拷锟斤拷锟斤拷锟斤拷锟街  
1709 -* Output: pRegion 10锟斤拷ROI指锟诫(bool锟斤拷每锟斤拷锟斤拷小为锟斤拷图锟斤拷锟*图锟斤拷撸锟斤拷锟斤拷锟饺わ拷锟斤拷锟街滴 锟斤拷锟斤拷为0  
1710 - //regionAlarm 10锟斤拷ROI 锟斤拷锟斤拷锟斤拷志锟斤拷bool锟斤拷  
1711 - pAlarmInfo 10锟斤拷ROI 锟斤拷锟斤拷锟斤拷志锟斤拷int锟斤拷 1622 +* Input: numROI ROI个数
  1623 + pRegionInfo ROI区域
  1624 + iflog true:输出日志 false:不输出日志
  1625 +* Output: pRegion 10个ROI指针(bool)每个大小为(图像宽*图像高)感兴趣区域值为1 其余为0
  1626 + //regionAlarm 10个ROI 报警标志(bool)
  1627 + pAlarmInfo 10个ROI 报警标志(int)
1712 * Return: 3 1 1628 * Return: 3 1
1713 *******************************************************************************/ 1629 *******************************************************************************/
1714 void printAlarmType(fstream *file, int style) 1630 void printAlarmType(fstream *file, int style)
@@ -1716,22 +1632,22 @@ void printAlarmType(fstream *file, int style) @@ -1716,22 +1632,22 @@ void printAlarmType(fstream *file, int style)
1716 switch (style) 1632 switch (style)
1717 { 1633 {
1718 case 1: 1634 case 1:
1719 - *file<<"锟斤拷锟斤拷锟斤拷锟, "; 1635 + *file<<"进入禁区, ";
1720 break; 1636 break;
1721 case 2: 1637 case 2:
1722 - *file<<"锟诫开锟斤拷锟斤拷, "; 1638 + *file<<"离开禁区, ";
1723 break; 1639 break;
1724 case 3: 1640 case 3:
1725 - *file<<"锟斤拷锟斤拷越锟斤拷, "; 1641 + *file<<"单向越界, ";
1726 break; 1642 break;
1727 case 4: 1643 case 4:
1728 - *file<<"双锟斤拷越锟斤拷, "; 1644 + *file<<"双向越界, ";
1729 break; 1645 break;
1730 case 5: 1646 case 5:
1731 - *file<<"锟角伙拷, "; 1647 + *file<<"徘徊, ";
1732 break; 1648 break;
1733 case 6: 1649 case 6:
1734 - *file<<"锟斤拷锟斤拷, "; 1650 + *file<<"丢包, ";
1735 break; 1651 break;
1736 default : 1652 default :
1737 break; 1653 break;
@@ -1741,12 +1657,12 @@ void printAlarmType(fstream *file, int style) @@ -1741,12 +1657,12 @@ void printAlarmType(fstream *file, int style)
1741 1657
1742 int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/) 1658 int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/)
1743 { 1659 {
1744 - //fstream file;//锟斤拷锟斤拷锟斤拷锟斤拷锟街 1660 + //fstream file;//用于输出日志
1745 if (numROI > MAXROINUM) 1661 if (numROI > MAXROINUM)
1746 { 1662 {
1747 return 0; 1663 return 0;
1748 } 1664 }
1749 - //锟皆讹拷锟斤拷锟斤拷锟斤拷锟斤拷确锟斤拷锟斤拷锟斤拷牡锟 1665 + //自动设置用于确定方向的点
1750 //for(int i = 0; i < numROI; i++) 1666 //for(int i = 0; i < numROI; i++)
1751 //{ 1667 //{
1752 // if (iflog) 1668 // if (iflog)
@@ -1760,13 +1676,13 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/) @@ -1760,13 +1676,13 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/)
1760 // 1676 //
1761 // if (pRegionInfo[i].AlarmInfo == 3) 1677 // if (pRegionInfo[i].AlarmInfo == 3)
1762 // { 1678 // {
1763 - // pRegionInfo[i].finaldir = get_ArrowDir(pRegionInfo[i].pROI[0], pRegionInfo[i].pROI[1], pRegionInfo[i].dirPoint);//确锟斤拷锟斤拷锟斤拷锟斤拷悖拷锟酵凤拷说锟斤拷锟斤拷锟 1679 + // pRegionInfo[i].finaldir = get_ArrowDir(pRegionInfo[i].pROI[0], pRegionInfo[i].pROI[1], pRegionInfo[i].dirPoint);//确定方向计算,箭头端点坐标
1764 // 1680 //
1765 // if (iflog) 1681 // if (iflog)
1766 // file<<", DirPoint("<<pRegionInfo[i].dirPoint.x<<","<<pRegionInfo[i].dirPoint.y<<")"; 1682 // file<<", DirPoint("<<pRegionInfo[i].dirPoint.x<<","<<pRegionInfo[i].dirPoint.y<<")";
1767 // 1683 //
1768 - // pRegionInfo[i].ArrowStartPoint = pStart; //锟斤拷头锟斤拷锟斤拷始锟剿碉拷 锟斤拷头指锟斤拷锟斤拷锟斤拷锟斤拷  
1769 - // pRegionInfo[i].ArrowEndPoint = pEnd; //锟斤拷头锟斤拷锟斤拷止锟剿碉拷 锟斤拷头指锟斤拷锟斤拷锟斤拷锟斤拷 1684 + // pRegionInfo[i].ArrowStartPoint = pStart; //箭头的起始端点 箭头指向正方形
  1685 + // pRegionInfo[i].ArrowEndPoint = pEnd; //箭头的终止端点 箭头指向正方形
1770 // } 1686 // }
1771 1687
1772 // if (iflog) 1688 // if (iflog)
@@ -1807,10 +1723,10 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/) @@ -1807,10 +1723,10 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/)
1807 } 1723 }
1808 1724
1809 1725
1810 - // 锟斤拷每一锟斤拷锟斤拷锟桔诧拷锟絉OI锟斤拷锟叫硷拷锟 1726 + // 对每一个待观察的ROI进行监测
1811 //for (int i = 0; i < numROI; i++) 1727 //for (int i = 0; i < numROI; i++)
1812 { 1728 {
1813 - // 锟斤拷每一锟斤拷锟斤拷锟斤拷趣锟斤拷锟斤拷锟斤拷斜锟街 锟斤拷锟斤拷趣锟斤拷锟斤拷pRegion值为1 锟斤拷锟斤拷为0 1729 + // 对每一个感兴趣区域进行标志 感兴趣区域pRegion值为1 其余为0
1814 //vibeMask(pRegionInfo[i].nPointNum, pRegionInfo[i].pROI, pRegion[i]); 1730 //vibeMask(pRegionInfo[i].nPointNum, pRegionInfo[i].pROI, pRegion[i]);
1815 } 1731 }
1816 1732
@@ -1916,7 +1832,7 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/) @@ -1916,7 +1832,7 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/)
1916 // int y = (int) (((LineMin.y - LineMax.y) / (double) (LineMin.x - LineMax.x)) * (double) (x - LineMin.x) + 0.5 + (double)LineMin.y); 1832 // int y = (int) (((LineMin.y - LineMax.y) / (double) (LineMin.x - LineMax.x)) * (double) (x - LineMin.x) + 0.5 + (double)LineMin.y);
1917 // //pRegion[GlobelWidth * y + x] = 1; 1833 // //pRegion[GlobelWidth * y + x] = 1;
1918 // 1834 //
1919 -// //原锟斤拷锟斤拷锟斤拷锟皆斤拷锟 锟斤拷锟斤拷芸锟睫革拷锟斤拷锟斤拷 1835 +// //原程序存在越界 苏晓芸修改如下
1920 // if (y > -1 && y < GlobelHeight && x > -1 && x < GlobelWidth) 1836 // if (y > -1 && y < GlobelHeight && x > -1 && x < GlobelWidth)
1921 // { 1837 // {
1922 // pRegion[GlobelWidth * y + x] = 1; 1838 // pRegion[GlobelWidth * y + x] = 1;
@@ -1932,7 +1848,7 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/) @@ -1932,7 +1848,7 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/)
1932 // int y = (int) (((LineMin.y - LineMax.y) / (double)(LineMin.x - LineMax.x)) * (double)(x - LineMin.x) + 0.5 + (double)LineMin.y); 1848 // int y = (int) (((LineMin.y - LineMax.y) / (double)(LineMin.x - LineMax.x)) * (double)(x - LineMin.x) + 0.5 + (double)LineMin.y);
1933 // //pRegion[GlobelWidth * y + x] = 1; 1849 // //pRegion[GlobelWidth * y + x] = 1;
1934 // 1850 //
1935 -// //原锟斤拷锟斤拷锟斤拷锟皆斤拷锟 锟斤拷锟斤拷芸锟睫革拷锟斤拷锟斤拷 1851 +// //原程序存在越界 苏晓芸修改如下
1936 // if (y > -1 && y < GlobelHeight && x > -1 && x < GlobelWidth) 1852 // if (y > -1 && y < GlobelHeight && x > -1 && x < GlobelWidth)
1937 // { 1853 // {
1938 // pRegion[GlobelWidth * y + x] = 1; 1854 // pRegion[GlobelWidth * y + x] = 1;
@@ -1947,7 +1863,7 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/) @@ -1947,7 +1863,7 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/)
1947 // { 1863 // {
1948 // //pRegion[GlobelWidth * i + pPointList[startp].x] = 1; 1864 // //pRegion[GlobelWidth * i + pPointList[startp].x] = 1;
1949 // 1865 //
1950 -// //原锟斤拷锟斤拷锟斤拷锟皆斤拷锟 锟斤拷锟斤拷芸锟睫革拷锟斤拷锟斤拷 1866 +// //原程序存在越界 苏晓芸修改如下
1951 // if (i > -1 && i < GlobelHeight && pPointList[startp].x > -1 && pPointList[startp].x < GlobelWidth) 1867 // if (i > -1 && i < GlobelHeight && pPointList[startp].x > -1 && pPointList[startp].x < GlobelWidth)
1952 // { 1868 // {
1953 // pRegion[GlobelWidth * i + pPointList[startp].x] = 1; 1869 // pRegion[GlobelWidth * i + pPointList[startp].x] = 1;
@@ -1966,7 +1882,7 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/) @@ -1966,7 +1882,7 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/)
1966 // int x = (int) (((LineMin.x - LineMax.x) / (double) (LineMin.y - LineMax.y)) * (double) (y - LineMin.y) + 0.5 + (double)LineMin.x); 1882 // int x = (int) (((LineMin.x - LineMax.x) / (double) (LineMin.y - LineMax.y)) * (double) (y - LineMin.y) + 0.5 + (double)LineMin.x);
1967 // //pRegion[GlobelWidth * y + x] = 1; 1883 // //pRegion[GlobelWidth * y + x] = 1;
1968 // 1884 //
1969 -// //原锟斤拷锟斤拷锟斤拷锟皆斤拷锟 锟斤拷锟斤拷芸锟睫革拷锟斤拷锟斤拷 1885 +// //原程序存在越界 苏晓芸修改如下
1970 // if (y > -1 && y < GlobelHeight && x > -1 && x < GlobelWidth) 1886 // if (y > -1 && y < GlobelHeight && x > -1 && x < GlobelWidth)
1971 // { 1887 // {
1972 // pRegion[GlobelWidth * y + x] = 1; 1888 // pRegion[GlobelWidth * y + x] = 1;
@@ -1982,7 +1898,7 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/) @@ -1982,7 +1898,7 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/)
1982 // int x = (int) (((LineMin.x - LineMax.x) / (double) (LineMin.y - LineMax.y)) * (double) (y - LineMin.y) + 0.5 + (double)LineMin.x); 1898 // int x = (int) (((LineMin.x - LineMax.x) / (double) (LineMin.y - LineMax.y)) * (double) (y - LineMin.y) + 0.5 + (double)LineMin.x);
1983 // //pRegion[GlobelWidth * y + x] = 1; 1899 // //pRegion[GlobelWidth * y + x] = 1;
1984 // 1900 //
1985 -// //原锟斤拷锟斤拷锟斤拷锟皆斤拷锟 锟斤拷锟斤拷芸锟睫革拷锟斤拷锟斤拷 1901 +// //原程序存在越界 苏晓芸修改如下
1986 // if (y > -1 && y < GlobelHeight && x > -1 && x < GlobelWidth) 1902 // if (y > -1 && y < GlobelHeight && x > -1 && x < GlobelWidth)
1987 // { 1903 // {
1988 // pRegion[GlobelWidth * y + x] = 1; 1904 // pRegion[GlobelWidth * y + x] = 1;
@@ -1997,7 +1913,7 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/) @@ -1997,7 +1913,7 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/)
1997 // { 1913 // {
1998 // //pRegion[GlobelWidth * pPointList[startp].y + i] = 1; 1914 // //pRegion[GlobelWidth * pPointList[startp].y + i] = 1;
1999 // 1915 //
2000 -// //原锟斤拷锟斤拷锟斤拷锟皆斤拷锟 锟斤拷锟斤拷芸锟睫革拷锟斤拷锟斤拷 1916 +// //原程序存在越界 苏晓芸修改如下
2001 // if (pPointList[startp].y > -1 && pPointList[startp].y < GlobelHeight && i > -1 && i < GlobelWidth) 1917 // if (pPointList[startp].y > -1 && pPointList[startp].y < GlobelHeight && i > -1 && i < GlobelWidth)
2002 // { 1918 // {
2003 // pRegion[GlobelWidth * pPointList[startp].y + i] = 1; 1919 // pRegion[GlobelWidth * pPointList[startp].y + i] = 1;
@@ -2007,7 +1923,7 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/) @@ -2007,7 +1923,7 @@ int RegionSurveillance::RSRegion(int numROI, int alarm_info/*, bool iflog*/)
2007 // } 1923 // }
2008 // } 1924 // }
2009 // 1925 //
2010 -// // 锟睫改憋拷欠锟绞 锟斤拷锟斤拷锟斤拷锟皆碉拷锟街撅拷锟轿 1926 +// // 修改标记方式 将区域边缘标志置为0
2011 // for (int i = 0; i < GlobelHeight; i++) 1927 // for (int i = 0; i < GlobelHeight; i++)
2012 // { 1928 // {
2013 // for (int j = 0; j < GlobelWidth; j++) 1929 // for (int j = 0; j < GlobelWidth; j++)
@@ -2153,9 +2069,8 @@ void RegionSurveillance::getObjectInfo(int ObjCount, MS_ObjectInfo* ObjInfo) @@ -2153,9 +2069,8 @@ void RegionSurveillance::getObjectInfo(int ObjCount, MS_ObjectInfo* ObjInfo)
2153 } 2069 }
2154 */ 2070 */
2155 // unique ID for current object 2071 // unique ID for current object
2156 - ObjInfo[i].TarBox = m_FinalArray[i].m_TarBox; //目锟斤拷锟斤拷泳锟斤拷锟  
2157 - ObjInfo[i].UniqueID = m_FinalArray[i].m_dwID; //锟斤拷前目锟斤拷锟斤拷氐锟絀D  
2158 - //printf("UniqueID = %d, cfd = %f\n", ObjInfo[i].UniqueID, ObjInfo[i].confidence); 2072 + ObjInfo[i].TarBox = m_FinalArray[i].m_TarBox; //目标外接矩形
  2073 + ObjInfo[i].UniqueID = m_FinalArray[i].m_dwID; //当前目标的特点ID
2159 } 2074 }
2160 } 2075 }
2161 2076
@@ -2167,7 +2082,6 @@ void RegionSurveillance::getDeleteInfo(int DelCount, MS_ObjectInfo* ObjInfo) @@ -2167,7 +2082,6 @@ void RegionSurveillance::getDeleteInfo(int DelCount, MS_ObjectInfo* ObjInfo)
2167 { 2082 {
2168 int dwPointCount = m_DelArray[i].m_ptArray.size(); 2083 int dwPointCount = m_DelArray[i].m_ptArray.size();
2169 ObjInfo[i].curPos = m_DelArray[i].m_ptArray[dwPointCount - 1]; 2084 ObjInfo[i].curPos = m_DelArray[i].m_ptArray[dwPointCount - 1];
2170 -  
2171 int temp_dwPointCount = dwPointCount; 2085 int temp_dwPointCount = dwPointCount;
2172 if (dwPointCount > MAXTRACENUM) 2086 if (dwPointCount > MAXTRACENUM)
2173 { 2087 {
@@ -2214,14 +2128,14 @@ void RegionSurveillance::getDeleteInfo(int DelCount, MS_ObjectInfo* ObjInfo) @@ -2214,14 +2128,14 @@ void RegionSurveillance::getDeleteInfo(int DelCount, MS_ObjectInfo* ObjInfo)
2214 } 2128 }
2215 */ 2129 */
2216 // unique ID for current object 2130 // unique ID for current object
2217 - ObjInfo[i].TarBox = m_DelArray[i].m_TarBox; //目锟斤拷锟斤拷泳锟斤拷锟  
2218 - ObjInfo[i].UniqueID = m_DelArray[i].m_dwID; //锟斤拷前目锟斤拷锟斤拷氐锟絀D 2131 + ObjInfo[i].TarBox = m_DelArray[i].m_TarBox; //?????????
  2132 + ObjInfo[i].UniqueID = m_DelArray[i].m_dwID; //??????????ID
2219 ObjInfo[i].confidence = m_DelArray[i].cfd; 2133 ObjInfo[i].confidence = m_DelArray[i].cfd;
2220 } 2134 }
2221 } 2135 }
2222 2136
2223 2137
2224 -// 锟斤拷图锟斤拷转锟斤拷为锟揭讹拷图锟斤拷 2138 +// 将图像转换为灰度图像
2225 void RegionSurveillance::VibeRGBToGray(unsigned char* RgbData, unsigned char* GrayData) 2139 void RegionSurveillance::VibeRGBToGray(unsigned char* RgbData, unsigned char* GrayData)
2226 { 2140 {
2227 int nHeight, nWidth; 2141 int nHeight, nWidth;
@@ -2240,11 +2154,11 @@ void RegionSurveillance::VibeRGBToGray(unsigned char* RgbData, unsigned char* Gr @@ -2240,11 +2154,11 @@ void RegionSurveillance::VibeRGBToGray(unsigned char* RgbData, unsigned char* Gr
2240 2154
2241 2155
2242 2156
2243 -//pAlarmInfo 1锟斤拷锟斤拷锟斤拷锟 2锟诫开锟斤拷锟斤拷 3锟斤拷锟斤拷越锟斤拷 4双锟斤拷越锟斤拷 5锟角伙拷 6锟斤拷锟斤拷 2157 +//pAlarmInfo 1进入禁区 2离开禁区 3单向越界 4双向越界 5徘徊 6丢包
2244 void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground ForegroundArray_i, int dwBestMatch, RegionInfo* pRegionInfo) 2158 void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground ForegroundArray_i, int dwBestMatch, RegionInfo* pRegionInfo)
2245 { 2159 {
2246 2160
2247 - // 目锟斤拷锟斤拷锟斤拷 2161 + // 目标锁定
2248 //ExternalRectangle(pRGBIn, ForegroundArray_i, dwBestMatch, widthStep, 255, 0, 0); 2162 //ExternalRectangle(pRGBIn, ForegroundArray_i, dwBestMatch, widthStep, 255, 0, 0);
2249 /* 2163 /*
2250 int dwStep = widthStep; 2164 int dwStep = widthStep;
@@ -2254,7 +2168,7 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore @@ -2254,7 +2168,7 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore
2254 unsigned char bBlue = (unsigned char) ((m_TargetArray[dwBestMatch].m_dwID % 13) * 20 + 15); 2168 unsigned char bBlue = (unsigned char) ((m_TargetArray[dwBestMatch].m_dwID % 13) * 20 + 15);
2255 2169
2256 2170
2257 - // 前锟斤拷目锟斤拷锟斤拷泳锟斤拷锟斤拷锟斤拷 2171 + // 前景目标外接矩形描绘
2258 for (int t = ForegroundArray_i.m_rtConnect.left; t <= ForegroundArray_i.m_rtConnect.right; t++) 2172 for (int t = ForegroundArray_i.m_rtConnect.left; t <= ForegroundArray_i.m_rtConnect.right; t++)
2259 { 2173 {
2260 pRGBIn[ForegroundArray_i.m_rtConnect.top * dwStep + t * 3] = 0; 2174 pRGBIn[ForegroundArray_i.m_rtConnect.top * dwStep + t * 3] = 0;
@@ -2281,11 +2195,11 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore @@ -2281,11 +2195,11 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore
2281 int c = ForegroundArray_i.m_rtConnect.left; 2195 int c = ForegroundArray_i.m_rtConnect.left;
2282 int d = ForegroundArray_i.m_rtConnect.right; 2196 int d = ForegroundArray_i.m_rtConnect.right;
2283 2197
2284 - // 锟斤拷锟斤拷锟斤拷 2198 + // 区域监控
2285 for (int ii = 0; ii < m_numROI; ii++) 2199 for (int ii = 0; ii < m_numROI; ii++)
2286 { 2200 {
2287 2201
2288 - if (pAlarmInfo[ii] == 1) //锟斤拷锟斤拷锟斤拷锟 2202 + if (pAlarmInfo[ii] == 1) //进入禁区
2289 { 2203 {
2290 //AccessToRestrictedAreas(pRegion[ii], dwBestMatch,a, b, c, d, ii); 2204 //AccessToRestrictedAreas(pRegion[ii], dwBestMatch,a, b, c, d, ii);
2291 /* 2205 /*
@@ -2295,7 +2209,7 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore @@ -2295,7 +2209,7 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore
2295 } 2209 }
2296 */ 2210 */
2297 } 2211 }
2298 - else if (pAlarmInfo[ii] == 2) //锟诫开锟斤拷锟斤拷 2212 + else if (pAlarmInfo[ii] == 2) //离开禁区
2299 { 2213 {
2300 //LeaveTheRestrictedAreas(pRegion[ii], dwBestMatch,a, b, c, d, ii); 2214 //LeaveTheRestrictedAreas(pRegion[ii], dwBestMatch,a, b, c, d, ii);
2301 /* 2215 /*
@@ -2306,7 +2220,7 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore @@ -2306,7 +2220,7 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore
2306 */ 2220 */
2307 } 2221 }
2308 2222
2309 - else if (pAlarmInfo[ii] == 3) //锟斤拷锟斤拷越锟斤拷 2223 + else if (pAlarmInfo[ii] == 3) //单向越界
2310 { 2224 {
2311 //OneWayCrossBorder(pRegion[ii], dwBestMatch, a, b, c, d, ii, pRegionInfo); 2225 //OneWayCrossBorder(pRegion[ii], dwBestMatch, a, b, c, d, ii, pRegionInfo);
2312 /* 2226 /*
@@ -2317,7 +2231,7 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore @@ -2317,7 +2231,7 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore
2317 */ 2231 */
2318 2232
2319 } 2233 }
2320 - else if (pAlarmInfo[ii] == 4) //双锟斤拷越锟斤拷 2234 + else if (pAlarmInfo[ii] == 4) //双向越界
2321 { 2235 {
2322 //TwoWayCrossBorder(pRegion[ii], dwBestMatch, a, b, c, d, ii); 2236 //TwoWayCrossBorder(pRegion[ii], dwBestMatch, a, b, c, d, ii);
2323 /* 2237 /*
@@ -2328,7 +2242,7 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore @@ -2328,7 +2242,7 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore
2328 */ 2242 */
2329 2243
2330 } 2244 }
2331 - else if (pAlarmInfo[ii] == 5) //锟角伙拷 2245 + else if (pAlarmInfo[ii] == 5) //徘徊
2332 { 2246 {
2333 //WanderMonitoring(pRegion[ii], dwBestMatch, a, b, c, d, ii, pRegionInfo, pRGBIn); 2247 //WanderMonitoring(pRegion[ii], dwBestMatch, a, b, c, d, ii, pRegionInfo, pRGBIn);
2334 /* 2248 /*
@@ -2338,7 +2252,7 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore @@ -2338,7 +2252,7 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore
2338 } 2252 }
2339 */ 2253 */
2340 } 2254 }
2341 - else if (pAlarmInfo[ii] == 6) //锟斤拷锟斤拷 2255 + else if (pAlarmInfo[ii] == 6) //丢包
2342 { 2256 {
2343 StayMonitoring( dwBestMatch, a, b, c, d, ii, pRegionInfo, pRGBIn); 2257 StayMonitoring( dwBestMatch, a, b, c, d, ii, pRegionInfo, pRGBIn);
2344 /* 2258 /*
@@ -2357,7 +2271,7 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore @@ -2357,7 +2271,7 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore
2357 2271
2358 2272
2359 2273
2360 - // 锟届迹锟斤拷锟 2274 + // 轨迹描绘
2361 //Trajectory(pRGBIn, ForegroundArray_i, dwBestMatch, width, height, widthStep); 2275 //Trajectory(pRGBIn, ForegroundArray_i, dwBestMatch, width, height, widthStep);
2362 /* 2276 /*
2363 int dwStep = widthStep; 2277 int dwStep = widthStep;
@@ -2368,14 +2282,14 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore @@ -2368,14 +2282,14 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore
2368 int dwPointNum = m_TargetArray[dwBestMatch].m_ptArray.size(); 2282 int dwPointNum = m_TargetArray[dwBestMatch].m_ptArray.size();
2369 CMPoint ptLast = m_TargetArray[dwBestMatch].m_ptArray[0]; 2283 CMPoint ptLast = m_TargetArray[dwBestMatch].m_ptArray[0];
2370 2284
2371 - // 锟斤拷目锟斤拷锟矫恳伙拷锟狡ワ拷锟斤拷锟斤拷锟叫憋拷锟斤拷 2285 + // 对目标的每一个匹配项进行遍历
2372 for (int l = 1; l < dwPointNum; l++) 2286 for (int l = 1; l < dwPointNum; l++)
2373 { 2287 {
2374 ForegroundArray_i.m_ptCenter = m_TargetArray[dwBestMatch].m_ptArray[l]; 2288 ForegroundArray_i.m_ptCenter = m_TargetArray[dwBestMatch].m_ptArray[l];
2375 if (ForegroundArray_i.m_ptCenter == ptLast) 2289 if (ForegroundArray_i.m_ptCenter == ptLast)
2376 { 2290 {
2377 // Draw a point 2291 // Draw a point
2378 - //锟斤拷锟侥匡拷锟斤拷锟斤拷牡锟 2292 + //描绘目标中心点
2379 pRGBIn[ForegroundArray_i.m_ptCenter.y * dwStep + ForegroundArray_i.m_ptCenter.x * 3] = bBlue; 2293 pRGBIn[ForegroundArray_i.m_ptCenter.y * dwStep + ForegroundArray_i.m_ptCenter.x * 3] = bBlue;
2380 pRGBIn[ForegroundArray_i.m_ptCenter.y * dwStep + ForegroundArray_i.m_ptCenter.x * 3 + 1] = bGreen; 2294 pRGBIn[ForegroundArray_i.m_ptCenter.y * dwStep + ForegroundArray_i.m_ptCenter.x * 3 + 1] = bGreen;
2381 pRGBIn[ForegroundArray_i.m_ptCenter.y * dwStep + ForegroundArray_i.m_ptCenter.x * 3 + 2] = bRed; 2295 pRGBIn[ForegroundArray_i.m_ptCenter.y * dwStep + ForegroundArray_i.m_ptCenter.x * 3 + 2] = bRed;
@@ -2458,13 +2372,13 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore @@ -2458,13 +2372,13 @@ void RegionSurveillance::MonitoringAlarm(unsigned char* pRGBIn, CForeground Fore
2458 } 2372 }
2459 2373
2460 /* 2374 /*
2461 -//锟斤拷泳锟斤拷锟斤拷锟斤拷 2375 +//外接矩形描绘
2462 void RegionSurveillance::ExternalRectangle(unsigned char* pRGBIn, CForeground ForegroundArray_i, int dwBestMatch, int widthStep, 2376 void RegionSurveillance::ExternalRectangle(unsigned char* pRGBIn, CForeground ForegroundArray_i, int dwBestMatch, int widthStep,
2463 int rgb_b, int rgb_g, int rgb_r) 2377 int rgb_b, int rgb_g, int rgb_r)
2464 { 2378 {
2465 int dwStep = widthStep; 2379 int dwStep = widthStep;
2466 2380
2467 - // 前锟斤拷目锟斤拷锟斤拷泳锟斤拷锟斤拷锟斤拷 2381 + // 前景目标外接矩形描绘
2468 for (int t = ForegroundArray_i.m_rtConnect.left; t <= ForegroundArray_i.m_rtConnect.right; t++) 2382 for (int t = ForegroundArray_i.m_rtConnect.left; t <= ForegroundArray_i.m_rtConnect.right; t++)
2469 { 2383 {
2470 pRGBIn[ForegroundArray_i.m_rtConnect.top * dwStep + t * 3] = rgb_b; 2384 pRGBIn[ForegroundArray_i.m_rtConnect.top * dwStep + t * 3] = rgb_b;
@@ -2487,7 +2401,7 @@ void RegionSurveillance::ExternalRectangle(unsigned char* pRGBIn, CForeground Fo @@ -2487,7 +2401,7 @@ void RegionSurveillance::ExternalRectangle(unsigned char* pRGBIn, CForeground Fo
2487 2401
2488 void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground ForegroundArray_i, int dwBestMatch, int width, int height, int widthStep) 2402 void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground ForegroundArray_i, int dwBestMatch, int width, int height, int widthStep)
2489 { 2403 {
2490 - // 锟届迹锟斤拷锟 2404 + // 轨迹描绘
2491 int dwStep = widthStep; 2405 int dwStep = widthStep;
2492 unsigned char bRed = (unsigned char) ((m_TargetArray[dwBestMatch].m_dwID % 3) * 85 + 85); 2406 unsigned char bRed = (unsigned char) ((m_TargetArray[dwBestMatch].m_dwID % 3) * 85 + 85);
2493 unsigned char bGreen = (unsigned char) ((m_TargetArray[dwBestMatch].m_dwID % 7) * 36 + 36); 2407 unsigned char bGreen = (unsigned char) ((m_TargetArray[dwBestMatch].m_dwID % 7) * 36 + 36);
@@ -2496,14 +2410,14 @@ void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground Foregroun @@ -2496,14 +2410,14 @@ void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground Foregroun
2496 int dwPointNum = m_TargetArray[dwBestMatch].m_ptArray.size(); 2410 int dwPointNum = m_TargetArray[dwBestMatch].m_ptArray.size();
2497 CMPoint ptLast = m_TargetArray[dwBestMatch].m_ptArray[0]; 2411 CMPoint ptLast = m_TargetArray[dwBestMatch].m_ptArray[0];
2498 2412
2499 - // 锟斤拷目锟斤拷锟矫恳伙拷锟狡ワ拷锟斤拷锟斤拷锟叫憋拷锟斤拷 2413 + // 对目标的每一个匹配项进行遍历
2500 for (int l = 1; l < dwPointNum; l++) 2414 for (int l = 1; l < dwPointNum; l++)
2501 { 2415 {
2502 ForegroundArray_i.m_ptCenter = m_TargetArray[dwBestMatch].m_ptArray[l]; 2416 ForegroundArray_i.m_ptCenter = m_TargetArray[dwBestMatch].m_ptArray[l];
2503 if (ForegroundArray_i.m_ptCenter == ptLast) 2417 if (ForegroundArray_i.m_ptCenter == ptLast)
2504 { 2418 {
2505 // Draw a point 2419 // Draw a point
2506 - //锟斤拷锟侥匡拷锟斤拷锟斤拷牡锟 2420 + //描绘目标中心点
2507 pRGBIn[ForegroundArray_i.m_ptCenter.y * dwStep + ForegroundArray_i.m_ptCenter.x * 3] = bBlue; 2421 pRGBIn[ForegroundArray_i.m_ptCenter.y * dwStep + ForegroundArray_i.m_ptCenter.x * 3] = bBlue;
2508 pRGBIn[ForegroundArray_i.m_ptCenter.y * dwStep + ForegroundArray_i.m_ptCenter.x * 3 + 1] = bGreen; 2422 pRGBIn[ForegroundArray_i.m_ptCenter.y * dwStep + ForegroundArray_i.m_ptCenter.x * 3 + 1] = bGreen;
2509 pRGBIn[ForegroundArray_i.m_ptCenter.y * dwStep + ForegroundArray_i.m_ptCenter.x * 3 + 2] = bRed; 2423 pRGBIn[ForegroundArray_i.m_ptCenter.y * dwStep + ForegroundArray_i.m_ptCenter.x * 3 + 2] = bRed;
@@ -2589,26 +2503,26 @@ void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground Foregroun @@ -2589,26 +2503,26 @@ void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground Foregroun
2589 2503
2590 /****************************************************************************** 2504 /******************************************************************************
2591 * Function: RAccessToRestrictedAreas 2505 * Function: RAccessToRestrictedAreas
2592 -* Description: 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷  
2593 -* Input: pRegion_i 锟斤拷锟斤拷趣锟斤拷锟斤拷锟斤拷  
2594 - dwBestMatch 目锟斤拷锟斤拷锟斤拷  
2595 - ForBottom 锟斤拷前前锟斤拷锟斤拷泳锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟叫≈  
2596 - ForTop 锟斤拷前前锟斤拷锟斤拷泳锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷值  
2597 - ForLeft 锟斤拷前前锟斤拷锟斤拷泳锟斤拷魏锟斤拷锟斤拷锟斤拷锟叫≈  
2598 - ForRight 锟斤拷前前锟斤拷锟斤拷泳锟斤拷魏锟斤拷锟斤拷锟斤拷锟斤拷值  
2599 - indexROI ROI 锟斤拷锟斤拷  
2600 -* Output: m_TargetArray 目锟斤拷锟斤拷息 2506 +* Description: 进入禁区监测
  2507 +* Input: pRegion_i 感兴趣区域标记
  2508 + dwBestMatch 目标索引
  2509 + ForBottom 当前前景外接矩形纵坐标最小值
  2510 + ForTop 当前前景外接矩形纵坐标最大值
  2511 + ForLeft 当前前景外接矩形横坐标最小值
  2512 + ForRight 当前前景外接矩形横坐标最大值
  2513 + indexROI ROI 索引
  2514 +* Output: m_TargetArray 目标信息
2601 *******************************************************************************/ 2515 *******************************************************************************/
2602 //void RegionSurveillance::AccessToRestrictedAreas(bool *pRegion_i, int dwBestMatch, int ForBottom, int ForTop, int ForLeft, int ForRight, int indexROI) 2516 //void RegionSurveillance::AccessToRestrictedAreas(bool *pRegion_i, int dwBestMatch, int ForBottom, int ForTop, int ForLeft, int ForRight, int indexROI)
2603 //{ 2517 //{
2604 // 2518 //
2605 -// // 目锟斤拷锟斤拷泳锟斤拷锟斤拷锟揭伙拷锟斤拷呓锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷泳锟斤拷锟斤拷锟斤拷牡锟轿伙拷诮锟斤拷锟斤拷锟 2519 +// // 目标外接矩形有一个边进入禁区且外接矩形中心点位于禁区内
2606 // //if (pRegion_i[GlobelWidth * ForBottom + ForLeft] || 2520 // //if (pRegion_i[GlobelWidth * ForBottom + ForLeft] ||
2607 // // pRegion_i[GlobelWidth * ForTop + ForLeft] || 2521 // // pRegion_i[GlobelWidth * ForTop + ForLeft] ||
2608 // // pRegion_i[GlobelWidth * ForTop + ForRight] || 2522 // // pRegion_i[GlobelWidth * ForTop + ForRight] ||
2609 // // pRegion_i[GlobelWidth * ForBottom + ForRight]) 2523 // // pRegion_i[GlobelWidth * ForBottom + ForRight])
2610 // { 2524 // {
2611 -// //锟斤拷锟叫讹拷锟角凤拷锟斤拷锟斤拷锟斤拷趣锟斤拷锟斤拷某锟斤拷司锟斤拷锟斤拷锟斤拷牡锟斤拷锟斤拷锟斤拷锟斤拷锟揭猴拷锟斤拷锟斤拷锟斤拷锟斤拷愣硷拷锟斤拷锟斤拷锟斤拷锟斤拷卸锟轿拷锟斤拷锟 2525 +// //将判断是否进入感兴趣区域改成了矩形中心点的上下左右和中心五个点都进入区域,判定为进入
2612 // if (pRegion_i[GlobelWidth * (int) ((ForBottom + ForTop) / 2) + (ForLeft + ForRight) / 2] && \ 2526 // if (pRegion_i[GlobelWidth * (int) ((ForBottom + ForTop) / 2) + (ForLeft + ForRight) / 2] && \
2613 // pRegion_i[GlobelWidth * (int)((ForBottom + ForTop) / 2) + (ForLeft + ForRight) / 2 + 1] && \ 2527 // pRegion_i[GlobelWidth * (int)((ForBottom + ForTop) / 2) + (ForLeft + ForRight) / 2 + 1] && \
2614 // pRegion_i[GlobelWidth * (int)((ForBottom + ForTop) / 2) + (ForLeft + ForRight) / 2 - 1] && \ 2528 // pRegion_i[GlobelWidth * (int)((ForBottom + ForTop) / 2) + (ForLeft + ForRight) / 2 - 1] && \
@@ -2626,7 +2540,7 @@ void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground Foregroun @@ -2626,7 +2540,7 @@ void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground Foregroun
2626 // 2540 //
2627 //} 2541 //}
2628 2542
2629 -//锟诫开锟斤拷锟斤拷 2543 +//离开禁区
2630 //void RegionSurveillance::LeaveTheRestrictedAreas(bool *pRegion_i, int dwBestMatch, int ForBottom, int ForTop, int ForLeft, int ForRight, int indexROI) 2544 //void RegionSurveillance::LeaveTheRestrictedAreas(bool *pRegion_i, int dwBestMatch, int ForBottom, int ForTop, int ForLeft, int ForRight, int indexROI)
2631 //{ 2545 //{
2632 // if (pRegion_i[GlobelWidth * ForBottom + ForLeft] || 2546 // if (pRegion_i[GlobelWidth * ForBottom + ForLeft] ||
@@ -2664,11 +2578,11 @@ void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground Foregroun @@ -2664,11 +2578,11 @@ void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground Foregroun
2664 // m_TargetArray[dwBestMatch].pbAlarmType[indexROI] = 0; 2578 // m_TargetArray[dwBestMatch].pbAlarmType[indexROI] = 0;
2665 //} 2579 //}
2666 2580
2667 -//锟斤拷锟斤拷越锟斤拷  
2668 -//dir: 1 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟酵拷锟斤拷锟斤拷锟较碉拷锟 0锟斤拷锟斤拷锟斤拷 2581 +//单向越界
  2582 +//dir: 1 正方向(相对于通常坐标系) 0负方向
2669 //void RegionSurveillance::OneWayCrossBorder(bool *pRegion_i, int dwBestMatch, int ForBottom, int ForTop, int ForLeft, int ForRight, int indexROI, RegionInfo* pRegionInfo) 2583 //void RegionSurveillance::OneWayCrossBorder(bool *pRegion_i, int dwBestMatch, int ForBottom, int ForTop, int ForLeft, int ForRight, int indexROI, RegionInfo* pRegionInfo)
2670 //{ 2584 //{
2671 -// // 只要目锟斤拷锟斤拷泳锟斤拷锟斤拷锟揭伙拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟津报撅拷 2585 +// // 只要目标外接矩形有一个点进入区域则报警
2672 // int tar_size = m_TargetArray[dwBestMatch].m_ptArray.size(); 2586 // int tar_size = m_TargetArray[dwBestMatch].m_ptArray.size();
2673 // int xmin = min(ForLeft, ForRight), xmax = max(ForLeft, ForRight), ymin = min(ForBottom, ForTop), ymax = max(ForBottom, ForTop); 2587 // int xmin = min(ForLeft, ForRight), xmax = max(ForLeft, ForRight), ymin = min(ForBottom, ForTop), ymax = max(ForBottom, ForTop);
2674 // for (int iy = ymin; iy <= ymax; iy++) 2588 // for (int iy = ymin; iy <= ymax; iy++)
@@ -2681,7 +2595,7 @@ void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground Foregroun @@ -2681,7 +2595,7 @@ void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground Foregroun
2681 // point_x = m_TargetArray[dwBestMatch].m_ptArray[tar_size - 4].x; 2595 // point_x = m_TargetArray[dwBestMatch].m_ptArray[tar_size - 4].x;
2682 // point_y = m_TargetArray[dwBestMatch].m_ptArray[tar_size - 4].y; 2596 // point_y = m_TargetArray[dwBestMatch].m_ptArray[tar_size - 4].y;
2683 // 2597 //
2684 -// // 锟叫断凤拷锟斤拷 2598 +// // 判断方向
2685 // if (indexROI >= 0 && indexROI < m_numROI && pRegionInfo[indexROI].nPointNum >= 2) 2599 // if (indexROI >= 0 && indexROI < m_numROI && pRegionInfo[indexROI].nPointNum >= 2)
2686 // { 2600 // {
2687 // if (abs(pRegionInfo[indexROI].pROI[0].x - pRegionInfo[indexROI].pROI[1].x) >= 1) 2601 // if (abs(pRegionInfo[indexROI].pROI[0].x - pRegionInfo[indexROI].pROI[1].x) >= 1)
@@ -2916,10 +2830,10 @@ void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground Foregroun @@ -2916,10 +2830,10 @@ void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground Foregroun
2916 // m_TargetArray[dwBestMatch].pbAlarmType[indexROI] = 0; 2830 // m_TargetArray[dwBestMatch].pbAlarmType[indexROI] = 0;
2917 //} 2831 //}
2918 2832
2919 -////双锟斤拷越锟斤拷 2833 +////双向越界
2920 //void RegionSurveillance::TwoWayCrossBorder(bool *pRegion_i, int dwBestMatch, int ForBottom, int ForTop, int ForLeft, int ForRight, int indexROI) 2834 //void RegionSurveillance::TwoWayCrossBorder(bool *pRegion_i, int dwBestMatch, int ForBottom, int ForTop, int ForLeft, int ForRight, int indexROI)
2921 //{ 2835 //{
2922 -// // 只要目锟斤拷锟斤拷泳锟斤拷锟斤拷锟揭伙拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟津报撅拷 2836 +// // 只要目标外接矩形有一个点进入区域则报警
2923 // int xmin = min(ForLeft, ForRight), xmax = max(ForLeft, ForRight), ymin = min(ForBottom, ForTop), ymax = max(ForBottom, ForTop); 2837 // int xmin = min(ForLeft, ForRight), xmax = max(ForLeft, ForRight), ymin = min(ForBottom, ForTop), ymax = max(ForBottom, ForTop);
2924 // for (int iy = ymin; iy <= ymax; iy++) 2838 // for (int iy = ymin; iy <= ymax; iy++)
2925 // { 2839 // {
@@ -2937,10 +2851,10 @@ void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground Foregroun @@ -2937,10 +2851,10 @@ void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground Foregroun
2937 // m_TargetArray[dwBestMatch].pbAlarmType[indexROI] = 0; 2851 // m_TargetArray[dwBestMatch].pbAlarmType[indexROI] = 0;
2938 //} 2852 //}
2939 2853
2940 -////双锟斤拷越锟斤拷 2854 +////双向越界
2941 //void RegionSurveillance::TwoWayCrossBorder(bool *pRegion_i, int dwBestMatch, int ForBottom, int ForTop, int ForLeft, int ForRight, int indexROI) 2855 //void RegionSurveillance::TwoWayCrossBorder(bool *pRegion_i, int dwBestMatch, int ForBottom, int ForTop, int ForLeft, int ForRight, int indexROI)
2942 //{ 2856 //{
2943 -// // 只要目锟斤拷锟斤拷泳锟斤拷锟斤拷锟揭伙拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟津报撅拷 2857 +// // 只要目标外接矩形有一个点进入区域则报警
2944 // int xmin = min(ForLeft, ForRight), xmax = max(ForLeft, ForRight), ymin = min(ForBottom, ForTop), ymax= max(ForBottom, ForTop); 2858 // int xmin = min(ForLeft, ForRight), xmax = max(ForLeft, ForRight), ymin = min(ForBottom, ForTop), ymax= max(ForBottom, ForTop);
2945 // for (int iy = ymin; iy <= ymax; iy++) 2859 // for (int iy = ymin; iy <= ymax; iy++)
2946 // { 2860 // {
@@ -2958,7 +2872,7 @@ void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground Foregroun @@ -2958,7 +2872,7 @@ void RegionSurveillance::Trajectory(unsigned char* pRGBIn, CForeground Foregroun
2958 // m_TargetArray[dwBestMatch].pbAlarmType[indexROI] = -1; 2872 // m_TargetArray[dwBestMatch].pbAlarmType[indexROI] = -1;
2959 //} 2873 //}
2960 2874
2961 -// 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷瞥锟 0 锟斤拷锟斤拷 1锟狡筹拷 2875 +// 监测遗留或移除 0 遗留 1移除
2962 bool RegionSurveillance::detectLeftRemove(unsigned char* pRGBIn, int ForBottom, int ForTop, int ForLeft, int ForRight) 2876 bool RegionSurveillance::detectLeftRemove(unsigned char* pRGBIn, int ForBottom, int ForTop, int ForLeft, int ForRight)
2963 { 2877 {
2964 bool flag; 2878 bool flag;
@@ -3071,11 +2985,11 @@ bool RegionSurveillance::detectLeftRemove(unsigned char* pRGBIn, int ForBottom, @@ -3071,11 +2985,11 @@ bool RegionSurveillance::detectLeftRemove(unsigned char* pRGBIn, int ForBottom,
3071 } 2985 }
3072 } 2986 }
3073 2987
3074 - if (ratio >= 0.85 && ratio <= 1.0) //锟斤拷锟斤拷锟绞撅拷瞥锟 2988 + if (ratio >= 0.85 && ratio <= 1.0) //相近表示移除
3075 { 2989 {
3076 flag = 1; 2990 flag = 1;
3077 } 2991 }
3078 - else // 锟斤拷锟斤拷锟绞撅拷锟斤拷锟 2992 + else // 否则表示遗留
3079 { 2993 {
3080 flag = 0; 2994 flag = 0;
3081 } 2995 }
@@ -3091,10 +3005,10 @@ bool CTargetFunc (CTarget &amp;a, CTarget &amp;b) @@ -3091,10 +3005,10 @@ bool CTargetFunc (CTarget &amp;a, CTarget &amp;b)
3091 else 3005 else
3092 return false; 3006 return false;
3093 } 3007 }
3094 -// 锟角伙拷锟斤拷锟 3008 +// 徘徊监测
3095 void RegionSurveillance::WanderMonitoring(bool *pRegion_i, int dwBestMatch, int ForBottom, int ForTop, int ForLeft, int ForRight, int indexROI, RegionInfo* pRegionInfo, unsigned char* pRGBIn) 3009 void RegionSurveillance::WanderMonitoring(bool *pRegion_i, int dwBestMatch, int ForBottom, int ForTop, int ForLeft, int ForRight, int indexROI, RegionInfo* pRegionInfo, unsigned char* pRGBIn)
3096 { 3010 {
3097 - // 目锟斤拷锟斤拷泳锟斤拷锟斤拷锟揭伙拷锟斤拷呓锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷泳锟斤拷锟斤拷锟斤拷牡锟轿伙拷诮锟斤拷锟斤拷锟 3011 + // 目标外接矩形有一个边进入禁区且外接矩形中心点位于禁区内
3098 bool flag = 0; 3012 bool flag = 0;
3099 3013
3100 if ((pRegion_i[GlobelWidth * ForBottom + ForLeft] || 3014 if ((pRegion_i[GlobelWidth * ForBottom + ForLeft] ||
@@ -3121,7 +3035,7 @@ void RegionSurveillance::WanderMonitoring(bool *pRegion_i, int dwBestMatch, int @@ -3121,7 +3035,7 @@ void RegionSurveillance::WanderMonitoring(bool *pRegion_i, int dwBestMatch, int
3121 m_TargetArray[dwBestMatch].lastFrame = 0; 3035 m_TargetArray[dwBestMatch].lastFrame = 0;
3122 } 3036 }
3123 } 3037 }
3124 - if ((1 == m_TargetArray[dwBestMatch].m_ptArray.size() && m_TargetArray[dwBestMatch].nFrameCurr == 1) && m_TargetArray[dwBestMatch].m_bFirstInWander == true ) //锟斤拷锟斤拷锟角伙拷锟斤拷锟斤拷锟节o拷锟斤拷锟侥匡拷锟斤拷锟斤拷锟叫讹拷为锟铰讹拷锟襟,斤拷锟斤拷锟铰讹拷锟斤拷锟絥FrameCurr锟斤拷锟斤拷锟斤拷为锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷咏锟斤拷亩锟斤拷锟斤拷nFrameCurr 3038 + if ((1 == m_TargetArray[dwBestMatch].m_ptArray.size() && m_TargetArray[dwBestMatch].nFrameCurr == 1) && m_TargetArray[dwBestMatch].m_bFirstInWander == true ) //因在徘徊区域内,检测目标对象判定为新对象,将该新对象的nFrameCurr,设置为该区域内最接近的对象的nFrameCurr
3125 { 3039 {
3126 double bestDistance = 0; 3040 double bestDistance = 0;
3127 CTarget best; 3041 CTarget best;
@@ -3199,7 +3113,7 @@ void RegionSurveillance::WanderMonitoring(bool *pRegion_i, int dwBestMatch, int @@ -3199,7 +3113,7 @@ void RegionSurveillance::WanderMonitoring(bool *pRegion_i, int dwBestMatch, int
3199 m_TargetArray[dwBestMatch].m_bFirstInWander = false; 3113 m_TargetArray[dwBestMatch].m_bFirstInWander = false;
3200 3114
3201 3115
3202 - // 锟叫讹拷模锟斤拷锟角凤拷锟斤拷懈锟斤拷锟 0 锟斤拷锟斤拷 1锟狡筹拷 3116 + // 判断模板是否进行更新 0 遗留 1移除
3203 left_flag_now_w = detectLeftRemove(pRGBIn, ForBottom, ForTop, ForLeft, ForRight); 3117 left_flag_now_w = detectLeftRemove(pRGBIn, ForBottom, ForTop, ForLeft, ForRight);
3204 } 3118 }
3205 else 3119 else
@@ -3227,10 +3141,10 @@ void RegionSurveillance::WanderMonitoring(bool *pRegion_i, int dwBestMatch, int @@ -3227,10 +3141,10 @@ void RegionSurveillance::WanderMonitoring(bool *pRegion_i, int dwBestMatch, int
3227 } 3141 }
3228 3142
3229 3143
3230 -// 锟斤拷锟斤拷锟斤拷锟 3144 +// 丢包监测
3231 void RegionSurveillance::StayMonitoring( int dwBestMatch, int ForBottom, int ForTop, int ForLeft, int ForRight, int indexROI, RegionInfo* pRegionInfo, unsigned char* pRGBIn) 3145 void RegionSurveillance::StayMonitoring( int dwBestMatch, int ForBottom, int ForTop, int ForLeft, int ForRight, int indexROI, RegionInfo* pRegionInfo, unsigned char* pRGBIn)
3232 { 3146 {
3233 - // 目锟斤拷锟斤拷泳锟斤拷锟斤拷锟揭伙拷锟斤拷呓锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷泳锟斤拷锟斤拷锟斤拷牡锟轿伙拷诮锟斤拷锟斤拷锟 3147 + // 目标外接矩形有一个边进入禁区且外接矩形中心点位于禁区内
3234 int tar_size = m_TargetArray[dwBestMatch].m_ptArray.size(); 3148 int tar_size = m_TargetArray[dwBestMatch].m_ptArray.size();
3235 int cur_dis; 3149 int cur_dis;
3236 bool flag = 0; 3150 bool flag = 0;
@@ -3290,7 +3204,7 @@ void RegionSurveillance::StayMonitoring( int dwBestMatch, int ForBottom, int For @@ -3290,7 +3204,7 @@ void RegionSurveillance::StayMonitoring( int dwBestMatch, int ForBottom, int For
3290 } 3204 }
3291 } 3205 }
3292 3206
3293 - // 锟叫讹拷模锟斤拷锟角凤拷锟斤拷懈锟斤拷锟 0 锟斤拷锟斤拷 1锟狡筹拷 3207 + // 判断模板是否进行更新 0 遗留 1移除
3294 left_flag_now_s = detectLeftRemove(pRGBIn, ForBottom, ForTop, ForLeft, ForRight); 3208 left_flag_now_s = detectLeftRemove(pRGBIn, ForBottom, ForTop, ForLeft, ForRight);
3295 } 3209 }
3296 //else 3210 //else
@@ -3330,7 +3244,7 @@ void RegionSurveillance::RSrelease() @@ -3330,7 +3244,7 @@ void RegionSurveillance::RSrelease()
3330 pAlarmInfo = NULL; 3244 pAlarmInfo = NULL;
3331 } 3245 }
3332 3246
3333 - // 锟酵凤拷m_TargetArray 3247 + // 释放m_TargetArray
3334 int i; 3248 int i;
3335 for (i = 0; i < (int)m_TargetArray.size(); i++) 3249 for (i = 0; i < (int)m_TargetArray.size(); i++)
3336 { 3250 {