【问题标题】:How can I apply the hough circle method to a thresholded image?如何将霍夫圆方法应用于阈值图像?
【发布时间】:2019-09-27 12:18:16
【问题描述】:

我目前有一个可以使用 openCV 检测彩球的程序,我想添加 HoughCircle 方法以使其更好。

我有想法将 HoughCircle 方法应用于我从 inRange 方法获得的阈值图像,但不幸的是它不起作用。 我看到HoughCircle方法只拍灰度图像,有没有办法将阈值图像传递给它?

我就是这样做的:

int isBall(Mat threshold){
    Mat temp;
    threshold.copyTo(temp);
    std::vector<Vec3f> circles;
    HoughCircles(temp, circles, CV_HOUGH_GRADIENT, 1, temp.rows/8 
                                                    , 100
                                                    , 50 
                                                    , 15 /* min radius */
                                                    , 200 /* max radius */
                                                    );
    printf("nb circles = %d\n", circles.size());
    if(circles.size() > 0){
        return 1;
    }
    return 0;

}

阈值图像来自:

inRange(HSV,Scalar(H_MIN,S_MIN,V_MIN),Scalar(H_MAX,S_MAX,V_MAX),threshold);

这是我可以获得的阈值图像示例: https://www.noelshack.com/2019-39-5-1569586501-threshold.png

提前感谢您的帮助。

【问题讨论】:

    标签: c++ opencv hough-transform threshold


    【解决方案1】:

    您面临的问题与 HoughCircles 中使用的参数有关。如果将示例图像转换为灰度图像,则可以很好地使用示例图像。

    罪魁祸首是param2=50,也就是threshold for circle centers at detection stage。如果将其设置为较小的值,则算法将能够返回圆。

    我已经使用param2=10 测试了HoughCircles(),结果是这样的:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-23
      • 1970-01-01
      • 1970-01-01
      • 2016-12-03
      • 2014-05-12
      相关资源
      最近更新 更多