OpenCV(C语言)在白色区域周围画圆
how can I draw a circle around a white space in a image file with OpenCV (C language)?
image example:
thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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.