Reputation: 17
import cv2
#read camera
webcam = cv2.VideoCapture(1)
#vizualize camera
while True:
ret, frame = webcam.read()
frame = cv2.resize(frame, (1280, 720))
cv2.imshow('frame', frame)
if cv2.waitKey(40) & 0xFF == ord('q'):
break
webcam.release()
cv2.destroyAllWindows()
The original on Camera app:
The one displayed by cv2:
The video displayed by the cv2 library is not the same as the original in the Camera app. It appears that almost a quarter of the frame is being cut off. I have try resize it but there is no help. what is the problem and how can i fix it. thank you.
Upvotes: 0
Views: 33
Reputation: 17
I just discovered that I can resolve this issue by simply setting the desired resolution using these two commands:
cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
Upvotes: 0