使用霍夫变换的C ++ OpenCV三角检测 [英] C++ OpenCV triangle detection using hough transform
问题描述
我正在寻找一些示例,该示例如何实现用于三角形检测的霍夫变换.用于符号检测.我已经完成了颜色阈值处理.您对使用 HoughLinesP()
有什么看法?我正在做Canny,然后阈值化并使用HoughLines,但是结果是很多行,而且我的标志里面也有.我不认为现在找到路口将是我的解决方案.
I'm looking for some examples how to implement hough transform for triangles detection. It's for sign detection needed. I've already done color thresholding. What do you think about using HoughLinesP()
? I'm doing Canny, then thresholding and using HoughLines, but the result is many of lines and there are inside my sign too. I don't think finding intersection now will be my solution.
您怎么看?有任何例子或其他想法吗?我也尝试过 findContours()
,但是三角形是圆形的,因此它们需要大的近似值,并且可以检测到满是垃圾.
What do you think? Any examples or other ideas? I've also tried findContours()
, but the triangles are rounded, so they need big approximation and it makes detecting full of trash.
推荐答案
您正在寻找的是通用霍夫变换,是霍夫变换的通用形式,可以检测任意形状.这样,您可以将形状指定为三角形.
What you are looking for is Generalized Hough Transform which is a generalization of Hough transform to detect arbitrary shapes. This way, you can specify your shape as a triangle.
OpenCV中有一个通用Hough的实现: http://docs.opencv.org/master/d7/dd4/classcv_1_1GeneralizedHough.html您可以使用setTemplate方法定义形状.
There is an implementation of Generalized Hough in OpenCV: http://docs.opencv.org/master/d7/dd4/classcv_1_1GeneralizedHough.html and you can use the setTemplate method to define your shape.
这篇关于使用霍夫变换的C ++ OpenCV三角检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!