【发布时间】: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