S Andrew
S Andrew

Reputation: 7298

How to adjust aspect ratio of OpenCV live video feed as per the Camera (Python)

I have python code which is showing the live video feed from usb Logitech Camera. Below is the code snippet:

vcap = cv2.VideoCapture(1)

while (1):
    ret, frame = vcap.read()

    cv2.imshow('Input', frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

vcap.release()
cv2.destroyAllWindows()

Output:

enter image description here

Above is the screenshot taken from opencv window and below is the photo taken from windows default camera app.:

enter image description here

We can notice that opencv by defaults crop some of the left and right portion from the frame. How can remove this feature from opencv.?

Upvotes: 2

Views: 1920

Answers (1)

Yunus Temurlenk
Yunus Temurlenk

Reputation: 4377

This is about the resolution settings. Windows app. or OpenCV uses different resolutions. Cameras which have their own drivers you can't set their resolution settings by OpenCV.

Since your camera is a webcam(usb) camera, you can use set property. As mentioned here.

Upvotes: 2

Related Questions