0

I am using python and opencv to take an image; however, the image quality is not displaying the correct sized image.

When I run:

import cv2

cap = cv2.VideoCapture(0)
width=cap.get(3)
height=cap.get(4)
print(width,height)

This is printing the following, even though it is an 8-megapixel camera:

640.0 480.0

why is the image quality so much lower in the image taken by OpenCV than is advertised by the camera manufacturer?

helloworld12345
  • 176
  • 1
  • 4
  • 22
  • 2
    Take a look at this [question](https://stackoverflow.com/questions/19448078/python-opencv-access-webcam-maximum-resolution) – Jacob K Nov 14 '20 at 03:15
  • Look at the manual for the camera and find its supported resolutions and set the one you want. – Mark Setchell Nov 14 '20 at 09:44

1 Answers1

1

Sometimes the image quality can default to a lower resolution in OpenCV on a Raspberry Pi. You can manually set the resolution with the following function:

import cv2

def set_res(cap, width, height):
    cap.set(3, width)
    cap.set(4, height)

cap = cv2.VideoCapture(0)
set_res(cap, 1920, 1080)   # For 1080P
# set_res(cap, 3264, 2448)  <<< For full 8 megapixel capability

Beware that if you choose to show the frame, it may be much larger than your computer screen depending on your own monitor's resolution.

RappRapp
  • 56
  • 3