I am using
cap = cv2.VideoCapture(0)
and will eventually be inserting a video stream link for my video.
if circles is not None:
# convert the (x, y) coordinates and radius of the circles to integers
circles = np.round(circles[0, :]).astype("int")
# loop over the (x, y) coordinates and radius of the circles
for (x, y, r) in circles:
# draw the circle in the output image, then draw a rectangle in the image
# corresponding to the center of the circle
cv2.circle(output, (x, y), r, (0, 255, 0), 4)
cv2.rectangle(output, (x - 5, y - 5), (x + 5, y + 5), (0, 128, 255), -1)
time.sleep(1)
print ("Radius is: ")
print (r)
cv2.imshow('gray',gray)
cv2.imshow('frame',output)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
When a circle is in the frame the webcam starts and detects it with a green overlay. However, right when the circle is not detected or moved out of the frame then the video freezes and only resumes when a circle is put back in. How do I prevent this? I want a continuous video feed that will keep the camera going if no circle is present and also detect the circle if it is present.
Thanks
↧