检测斯诺克台球 [英] Detect Snooker Billiard Balls
问题描述
我正在使用OpenCV启动一个项目,以准确检测斯诺克球(台球)的位置和轮廓.
I am starting a project with OpenCV to accurately detect the position and contours of snooker balls (billiard balls).
这些是球:
我尝试了几种算法,但没有用.到目前为止,这是我所做的:
I've experimented with a few algorithms to no avail. This is what I've have done so far:
- HoughCircles :这几乎行不通.即使将参数调整为毫米分辨率,也只能检测到几个球,并且不能准确地检测到球的中心.
-HoughCircles: This barely works. Even adjusting parameters to millimeter resolution only results in a few balls detected, and the center of the balls are not accurately detected.
- Canny :在这里,我只能在球彼此不靠近的情况下检索球的轮廓.
-Canny: Here I only can retrieve ball contours if the balls are not close to one another.
- HSV颜色阈值:因为球不是一种颜色,所以这是行不通的.
-Threshold by color HSV: Because the balls are not one color this just doesn't work.
我想尝试其他算法,例如HaarCascadeDetection或SURF.
I want to experiment with other algorithms like HaarCascadeDetection or SURF.
你们怎么想?
推荐答案
仅使用霍夫圆变换(在使用参数一段时间后),我得到了一些不错的结果.我猜想诀窍是结合使用足够小的param2(以便进行更多检测)和限制搜索范围(以滤除误报).
I got some good results using just Hough circle transform (after playing with the parameters for awhile). I guess the trick is the combination of using a small enough param2 (to allow more detection) and restricting search radius (to filter out false positives).
circles = cv2.HoughCircles(img,cv2.cv.CV_HOUGH_GRADIENT,1,5,
param1=100,param2=10,minRadius=6,maxRadius=10)
我也消除了阴影,但是我不确定在您的情况下是否需要它. 这是一些测试结果.
Also I removed the shadows, but I'm not sure if it's needed in your case. Here's some test results.
这篇关于检测斯诺克台球的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!