OpenCV cvFindContours - 如何分离轮廓的组成部分
我一直在使用 OpenCV,经过大量的试验和错误,我成功地学会了如何检测照片中的圆圈(硬币)。一切都很好,除了当我将硬币直接放在彼此旁边时(如下所示,忽略第二张图像是颠倒的事实)。
似乎是因为硬币距离太近,cvFindContours 认为它们是同一个对象。我的问题是如何将这些轮廓分离成单独的对象,或者获取已分离的轮廓的列表。
我用于 cvFindContours 的参数是:
cvFindContours( img, storage, &contour, sizeof(CvContour), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE, cvPoint(0, 0) );
任何帮助或建议将不胜感激。
I've been playing around with OpenCV and with alot of trial and error have managed to learn how to detect circles (coins) in a photo. Everything is working great, except when I place coins directly next to each other (as seen below, ignore the fact that the 2nd image is upside down).
It seems because the coins are so close together cvFindContours think they are the same object. My question is how can I separate these contours into their separate objects, or get a list of contours that are already separated.
The parameters I used for cvFindContours are:
cvFindContours( img, storage, &contour, sizeof(CvContour), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE, cvPoint(0, 0) );
Any help or advice would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是很好,但它显示了如何到达那里:
This is not great, but it shows how to get there:
您可以尝试对图像进行阈值处理(cvThreshold),然后腐蚀( <一href="http://opencv.willowgarage.com/documentation/image_filtering.html?highlight=erode#cvErode" rel="nofollow">cvErode) 生成的二进制图像来分离硬币。然后找到腐蚀图像的轮廓。
You could try thresholding (cvThreshold) the image and then erode (cvErode) the resulting binary image to separate the coins. Then find the contours of the eroded image.