New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem in loop #3
Comments
can you please post the code too (the loop part) |
@saharshleo
|
this code is inside the loop (while True) |
which part of code is inside while True?, however if you want to select rectangles on different frames, below is the working code: from EasyROI import EasyROI
import cv2
from pprint import pprint
if __name__=='__main__':
roi_helper = EasyROI(verbose=True)
video_path = 'input/overpass.mp4'
# Initialize cam
cap = cv2.VideoCapture(video_path)
assert cap.isOpened(), 'Cannot capture source'
while(cap.isOpened()):
ret, frame = cap.read()
if ret == True:
# DRAW RECTANGULAR ROI
rect_roi = roi_helper.draw_rectangle(frame, 1)
print("Rectangle Example:")
pprint(rect_roi)
frame_temp = roi_helper.visualize_roi(frame, rect_roi)
cv2.imshow("frame", frame_temp)
key = cv2.waitKey(0)
if key & 0xFF == ord('q'):
cv2.destroyAllWindows()
if cv2.waitKey(5000) & 0xFF == 27: # wait for ESC key for 5seconds
break
else:
break
cap.release()
cv2.destroyAllWindows() Output: [DEBUG] Welcome to easyROI
[DEBUG] Entered draw_rectangle
Select a ROI and then press SPACE or ENTER button!
Cancel the selection process by pressing c button!
Rectangle Example:
{'roi': {0: {'br_x': 395,
'br_y': 489,
'h': 58,
'tl_x': 245,
'tl_y': 431,
'w': 150}},
'type': 'rectangle'}
[DEBUG] Entered draw_rectangle
Select a ROI and then press SPACE or ENTER button!
Cancel the selection process by pressing c button!
Rectangle Example:
{'roi': {0: {'br_x': 485,
'br_y': 556,
'h': 35,
'tl_x': 260,
'tl_y': 521,
'w': 225}},
'type': 'rectangle'}
[DEBUG] Entered draw_rectangle
Select a ROI and then press SPACE or ENTER button!
Cancel the selection process by pressing c button!
Rectangle Example:
{'roi': {0: {'br_x': 407,
'br_y': 588,
'h': 89,
'tl_x': 195,
'tl_y': 499,
'w': 212}},
'type': 'rectangle'}
[DEBUG] Entered draw_rectangle
Select a ROI and then press SPACE or ENTER button!
Cancel the selection process by pressing c button!
[DEBUG] Not all ROI's drawn
Rectangle Example:
{}
Thank You!!
|
Thank you ! |
Hello I have a Problem !
I putted the rectangle ROI in a loop but, it works only once, for the second time : i got the message for selecting ROI, but the window didn't show.
The text was updated successfully, but these errors were encountered: