简体   繁体   English

我正在使用 python 和 opencv 拍摄图像; 但是,图像质量未显示正确大小的图像

[英]I am using python and opencv to take an image; however, the image quality is not displaying the correct size image

I am using python and opencv to take an image;我正在使用 python 和 opencv 拍摄图像; 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:这是打印以下内容,即使它是一个 8 兆像素的相机:

640.0 480.0 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?为什么 OpenCV 拍摄的图像质量比相机制造商宣传的低得多?

Sometimes the image quality can default to a lower resolution in OpenCV on a Raspberry Pi.有时图像质量在 Raspberry Pi 上的 OpenCV 中默认为较低的分辨率。 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.请注意,如果您选择显示框架,根据您自己显示器的分辨率,它可能比您的计算机屏幕大得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM