does anyone know how do I calculate the distance between the blue point at the upper shape straight down to the border of that one below? I have the coordinates of the point. I was trying to check the color point by point until it reach the white part of the firgure below, but it is consuming too much hardware. (I start the positionY at the black part, but I may be doing something wrong...)
while(true){
p = pixelColor.ptr<Point3_<uchar> >( positionY, positionX);
if((p->z==255)&&(p->y==255)&&(p->x==255)){
cout<<"Found"<<endl;
break;
}
positionY++;
}
You could use dichotomy, you take a point half the height, if black, you work on the bottom half, if white, the top one then you do the same etc. until you converge. It's O(log2(height))
while your is O(height)
. You could however get errors depending the problem (ex: columns with white, black, white, black alternances.
You can also work on a single channel.
However, this is a pretty simple loop, if it's consuming too much hardware, you won't be able to do lot of things by the rest.