Ask Your Question
0

Can't get the resolution I want with opencv

asked 2018-07-22 22:11:21 -0600

zh gravatar image
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
cap.set(3,1920)
cap.set(4,1080)

while(1):
    _,frame = cap.read()
    cv2.imshow("capture", frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        cv2.imwrite("save.jpg", frame)
        break
cap.release()
cv2.destroyAllWindows()

When I set the resolution to 19201080, I get the save.jpg with 19201080. But I get save .jpg with 1280720 when I set the resolution to 12801024. Is it because the videocapture device just support some fixed resolution or the opencv?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-07-23 07:14:24 -0600

Are you sure that your capture device, so your webcam in this case supports that resolution? That seems the issue for me here. My guess your webcam only supports the 1920x1080 and 1280x720 format, which are identical aspect ratio of 0.5625. But your desired one is 0.8 and that is not a default screen resolution. My guess your webcam is the limiting factor here.

edit flag offensive delete link more

Comments

Thanks for your reply. Now I am quite sure it's the camera caused it. Because I changed another capture device and could get 1280x1024 output.

zh gravatar imagezh ( 2018-07-24 04:25:52 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-07-22 22:11:21 -0600

Seen: 402 times

Last updated: Jul 22 '18