边缘检测后获取边缘坐标(Canny)
我使用 OpenCV 的时间相当短,并对图像执行了 Canny 边缘检测,然后还执行了膨胀,以进一步将对象(在我的例子中是一个正方形)与背景分开。
我现在的问题是使用一种算法来识别二维中的可抓取区域,该算法要求我处理这些边缘中的点的坐标。有什么方法可以使用 OpenCV 来获取角点的坐标,以便我可以找到形成正方形边缘的线的方程?我知道正方形的大小。我的问题涉及二维坐标几何,因此需要坐标。
如果需要的话,我可以在边缘检测和膨胀后提供图像。非常感谢您的帮助。
I have been working with OpenCV for a fairly short time, and have performed Canny Edge Detection on an image, and also performed dilation after that to further separate the object (in my case a square) from the background.
My problem, now is to identify graspable regions in 2D using an algorithm that requires me to handle co-ordinates of the points in those edges. Is there any way I can use OpenCV to get the co-ordinates of the corners so I can find the equation of the lines forming the edge of the square? I know the size of the square. My problem involves 2D co-ordinate geometry, and hence the need for co-ordinates.
I can provide the image after edge detection and dilation if need be. Help would be appreciated a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只是提供第二种方法 - 不保证有效。
免责声明的原因是它仅适用于非常干净的结果,没有任何破损的边缘或 Canny 边缘中的间隙等。如果您需要更可靠的方法来查找矩形,霍夫变换是必要的。
Just offering a second method - not guaranteed to work.
The reason for the disclaimer is that it only works on very clean results, without any broken edges or gaps in the Canny edges, etc. If you need a more robust way of finding rectangles, Hough transform will be necessary.
您可以使用 OpenCV 中提供的角点检测器,例如 Harris 或角点特征值。 这是一个示例以及完整的代码。
如果其他功能也出现问题,您可能需要进行连接组件分析。
You could use the corner detectors provided in OpenCV like Harris or Corner Eigenvalues. Here's an example of that along with full-fledged code.
In case other features are also throwing up corners you may need to go in for connected component analysis.