I have a function where I detect a point from a video image and draw a dot on the frame. Now I need the x,y position of the dot elsewhere, but I can't get the information I need out of the function because of the while loop. As the code below is right now, the function only returns the last known value after the video stops. I also tried to put the return statement in the while loop, but the loop breaks because of the return statement. I'm talking about the xy_side that I need somewhere out of the function and I need it at real time (so not storing all the values in a list and showing the list afterwards). Can someone help me? The code is written with python.
def det_point(folder,fn,model):
cap = cv2.VideoCapture("./" + folder + "/" + fn)
red = (0, 0, 255)
while(cap.isOpened()):
ret, frame = cap.read()
crds = detect_point_prop(frame,model)
cntr_crds = float_to_int(crds[0])
start_crds = float_to_int(crds[1])
end_crds = float_to_int(crds[2])
frame = cv2.circle(frame, cntr_crds, 3, red, 5)
frame = cv2.rectangle(frame, start_crds, end_crds, green, 5)
cv2.imshow("Image", frame)
xy_side = cntr_crds
if cv2.waitKey(1) & 0xFF == ord('q'):
break
return xy_side