opencv 查找白色图片的一个黑点

一张白色图片,只有一个黑点,使用find contour能够找到,但是使用查找find area返回0.0


解决原因:

The area of polygon is 0 instead of 1, because the polygon is not a square with 1 pixel edge, but a point. This happened because polygon returned by findContours() is the polygon that connects centers of neighbor edge pixels (and there is a very good reason for this behavior). Your object has only one pixel and so returned polygon has only one vertex.

In general polygons returned by findContours() are not exact, and thus their area will almost always somewhat different from number of white pixels.



你可能感兴趣的:(OPENCV)