圆检测是跳跃
问题描述:
我用下面的代码来检测圈:圆检测是跳跃
gray = cv2.GaussianBlur(gray, (5, 5), 0);
gray = cv2.medianBlur(gray, 5)
kernel = np.ones((2, 2), np.uint8)
gray = cv2.erode(gray, kernel, iterations=1)
gray = cv2.dilate(gray, kernel, iterations=1)
circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, 200,
param1=100, param2=50, minRadius=0, maxRadius=150)
if circles is not None:
# Convert the (x,y) coordinate and radius of the circles
circles = np.round(circles[0, :]).astype("int")
# Loop over the (x,y) coordinate and radius of the circles
for (x, y, r) in circles:
# Draw the circle in the output
cv2.circle(fancy_frame, (x+x1, y+y1), r, (0, 255, 0), 4)
然而,当我发现的圆跳动。我怎样才能解决这个问题?有没有haar或svm来检测它?
这是我得到的输出:
我想检测实时视频
答
您的代码看起来不错,很有可能你只需要调整HoughCircles
parameters各界。
从降低dp
参数开始,它应该给你更多的检测。我来自OpenCV的样本图像上的文件夹运行houghcircles.py和检测最圆的其余部分:
$ python houghcircles.py your_image.png
霍夫检测圈是相当重的计算,所以可能很难运行这是实时的。此外,图像上的“圆圈”还不够完美,不便于算法。考虑训练神经网络来检测这些特征。
发布您的结果和预期结果。 – zindarod
请检查更新的问题 – user1241241
您必须应用一些跟踪算法,例如kalman-filter – eyllanesc