Change real camera resolution in OpenCV

天大地大妈咪最大 提交于 2021-02-19 03:40:19

问题


I'm trying to take 4k pictures using OpenCV, but when I change the resolution, the pictures just look resized instead of better quality.

I'm using OpenCV version 4, Python 3.6, Logitech BRIO 4k webcam and Windows 10.

If I don't change the camera resolution, it defaults to 640 x 480. If I change the resolution, the pictures just look blurred like they have been resized and not actually better quality. I can use the "Camera" app on Windows 10 to verify that the camera works with 4k resolution.

Here's what I'm doing:

import cv2
cam = cv2.VideoCapture(0)
cam.set(3, 3840)
cam.set(4, 2160)
cv2.namedWindow("test")

while True:
    ret, frame = cam.read()
    cv2.imshow("test", frame)

    if not ret:
        break
    k = cv2.waitKey(1)

    if k%256 == 32:
        # SPACE pressed
        img_name = "opencv_frame.png"
        cv2.imwrite(img_name, frame)
        print("{} written!".format(img_name))

I'd like to be able to change the actual resolution of the pictures.

来源:https://stackoverflow.com/questions/55690750/change-real-camera-resolution-in-opencv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!