Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 运动检测_Python_Opencv_Hough Transform - Fatal编程技术网

Python 运动检测

Python 运动检测,python,opencv,hough-transform,Python,Opencv,Hough Transform,我使用以下代码来检测圆: 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

我使用以下代码来检测圆:

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来检测它

这是我得到的输出:

[![Output][1]][1]


我想检测实时视频中的所有圆圈

你的代码看起来不错,很可能你只需要调整一下

从降低
dp
参数开始,它将为您提供更多检测。我从图像上的OpenCV samples文件夹中运行了houghcircles.py,它检测到其余大部分圆圈:

$ python houghcircles.py your_image.png


圆的Hough检测计算量很大,因此可能很难实时运行。此外,图像上的“圆圈”还远远不够完美,这使得算法变得不容易。考虑训练一个神经网络来检测这些特征。

你的代码看起来很好,很可能你只需要调整。 从降低
dp
参数开始,它将为您提供更多检测。我从图像上的OpenCV samples文件夹中运行了houghcircles.py,它检测到其余大部分圆圈:

$ python houghcircles.py your_image.png


圆的Hough检测计算量很大,因此可能很难实时运行。此外,图像上的“圆圈”还远远不够完美,这使得算法变得不容易。考虑训练一个神经网络,而不是检测这些特征。

张贴你的结果和预期结果。请检查更新的问题,你必须应用一些跟踪算法,例如Kalman。filter@user1241241我回滚了您的编辑。你是想问另一个问题吗?发布你的结果和预期结果。请检查更新的问题。你必须应用一些跟踪算法,例如卡尔曼-filter@user1241241我回滚了您的编辑。你是不是想问另一个问题?