Image Processing 34 - Detect if point is inside contour

Perform a contour point test.

double cv::pointPolygonTest(InputArray contour,
                        Point2f pt,
                        bool measureDist
                        )

This function determines whether the point is inside the contour, outside, or on an edge (or coincident with a vertex). It returns a positive (inner), negative (outer) or zero (on edge) value accordingly. When measureDist=false, the return values ​​are +1, -1, and 0, respectively. Otherwise, the return value is the signed distance between this point and the nearest contour edge.

See the example output of the function below, where each image pixel is tested against contours:

Guess you like

Origin blog.csdn.net/u013480226/article/details/123873267