Reputation: 127
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?
Upvotes: 0
Views: 562
Reputation: 66
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.
Upvotes: 1