边缘检测后获取边缘坐标(Canny) [英] Get edge co-ordinates after edge detection (Canny)
问题描述
我已经使用OpenCV了很短的时间,并且对图像进行了Canny Edge Detection,并且之后还进行了膨胀处理,以进一步将对象(在我的情况下为正方形)与背景分离.
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.
我的问题现在是使用一种算法来识别2D中的可抓取区域,该算法要求我处理这些边缘中的点的坐标.有什么方法可以使用OpenCV获取角的坐标,以便找到构成正方形边缘的直线的方程式?我知道正方形的大小.我的问题涉及二维坐标几何,因此需要坐标.
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.
推荐答案
仅提供第二种方法-不保证可以使用.
Just offering a second method - not guaranteed to work.
- 步骤1:提取连接的零部件及其轮廓.这可以在"Canny边缘检测"步骤之后应用.
- Step 1: extract connected component and their contours. This can be applied after the Canny Edge Detection step.
- FindContours
- BoundingRect -如果矩形始终是直立的(不是旋转)
- MinAreaRect -如果矩形是旋转的.
- BoundingRect - if the rectangles are always upright (not rotated)
- MinAreaRect - if the rectangles are rotated.
免责声明的原因是,它仅在非常干净的结果上起作用,而没有任何折断的边缘或Canny边缘中的间隙等.如果您需要更可靠的查找矩形的方法,请
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.
这篇关于边缘检测后获取边缘坐标(Canny)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- Step 1: extract connected component and their contours. This can be applied after the Canny Edge Detection step.