//返回找到的第一个的横距,横距计算点为原理point,depth_point的点
int CPeopleDetector::__BlobDistance(CvPoint *contourArray,CvPoint point,CvPoint depth_point ,int total)
{//2分法寻找相同点。contourArray同小到大排列
int i;
total /=2;
int comp = total;
int distance, minDis =-1;
int direction = depth_point.x - point.x;//>0 凹点在左,寻找右点(>0)//<0 凹点在右(寻找点-原来点<0)
while (total>0)//第1,2个,倒数第1,2个不做比较
{
total /=2;//每次除2
if (point.y == contourArray[comp].y)
{
distance =abs(point.x - contourArray[comp].x);
if (distance< minDis||minDis == -1){
minDis = distance;
}
}
else{
if(point.y > contourArray[comp].y){//在后面
comp = comp + total;//comp + (total-comp)/2
}
else{//相同点在前面
comp = comp - total;
}
}
}
return minDis;
}
int CPeopleDetector::__BlobDistance(CvPoint *contourArray,CvPoint point,CvPoint depth_point ,int total)
{//2分法寻找相同点。contourArray同小到大排列
int i;
total /=2;
int comp = total;
int distance, minDis =-1;
int direction = depth_point.x - point.x;//>0 凹点在左,寻找右点(>0)//<0 凹点在右(寻找点-原来点<0)
while (total>0)//第1,2个,倒数第1,2个不做比较
{
total /=2;//每次除2
if (point.y == contourArray[comp].y)
{
distance =abs(point.x - contourArray[comp].x);
if (distance< minDis||minDis == -1){
minDis = distance;
}
}
else{
if(point.y > contourArray[comp].y){//在后面
comp = comp + total;//comp + (total-comp)/2
}
else{//相同点在前面
comp = comp - total;
}
}
}
return minDis;
}