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

来源:互联网 发布:cos眼妆教程知乎 编辑:程序博客网 时间:2024/04/29 02:50

一张白色图片,只有一个黑点,使用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.