I have a script I'm testing:
import cv2
cap = cv2.VideoCapture(config['camera_number'])
frame_width = cap.get(3)
frame_height = cap.get(4)
print('w: ' + str(frame_width) + ', h: ' + str(frame_height))
while(True):
ret, frame = cap.read()
cv2.imshow('preview', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cap.destroyAllWindows()
I thought my code would run in order. However, the first thing I see is the preview window. When I close it by pressing "q", it then prints the frame width and height. Why is this?