First you can use FindContours to find all (in your case 1) contours (blobs/regions) in the image, then you can draw a circle or any other shape you want around the contour.
You don't really need opencv for that, you just loop over your image and calculate the bounding box surrounding the white blob, get the center and the radius of your circle is the length from the center to any corner. Then just use GDI or something to draw your circle.
发布评论
评论(3)
首先,您可以使用
FindContours
查找图像中的所有(在您的情况下为 1)轮廓(斑点/区域),然后您可以在轮廓周围绘制一个圆或任何其他您想要的形状。编辑:要绘制一个圆圈,您可以使用
圆
。First you can use
FindContours
to find all (in your case 1) contours (blobs/regions) in the image, then you can draw a circle or any other shape you want around the contour.Edit: To draw a circle you can use
Circle
.您可以先计算矩,然后从中获取圆信息。
you can compute moments first, then get circle info from it.
你实际上并不需要 opencv,你只需循环图像并计算白色斑点周围的边界框,获取中心,圆的半径就是从中心到任意角的长度。然后用GDI或者其他东西来画你的圆。
You don't really need opencv for that, you just loop over your image and calculate the bounding box surrounding the white blob, get the center and the radius of your circle is the length from the center to any corner. Then just use GDI or something to draw your circle.