I want to get intersections between a blob’s outline and a line. I find that I can draw out the intersection of the blob’s outline and a very thin rectangle by doing this:
int num = contours.nBlobs;//get blob's contour points number
if(num>0){
npts=contours.blobs[0].nPts;
ofSetHexColor(0xb5de10);
ofPushMatrix();
ofSetPolyMode(OF_POLY_WINDING_ABS_GEQ_TWO);
//ofSetPolyMode(OF_POLY_WINDING_NONZERO);
ofBeginShape();
for(int i=0; i<npts; i++){ //draw the blobs
int x = contours.blobs[0].pts[i].x;
int y = contours.blobs[0].pts[i].y+500;
ofVertex(x,y);
}
ofNextContour(true);
ofVertex(w/2,h+500); // a very thin rectangle
ofVertex(w/2+2,h+500);
ofVertex(w/2+2,h/2);
ofVertex(w/2,h/2);
ofEndShape(true);
ofPopMatrix();
}
But still cannot get the upper intersection point and lower intersection point’s coordinates. Any one have an idea how to do that??
Thank so much.