![](/img/trans.png)
[英]How can i return the the OpenCV Frame from my multithreaded camera code to be shown in Flask?
[英]How can I test the actual resolution of my camera when I acquire a frame using OpenCV?
我正在使用 Python/OpenCV,从 USB 网络摄像头(罗技 C615 摄像头,据说是高清 1080p)获取帧。 1080p 具有 16:9 的纵横比,因此我应该能够以所有这些分辨率获取图像:
1920 x 1080
1600 x 900
1366 x 768
1280 x 720
1024 x 576
但是我没有编写相机驱动程序,所以我怎么知道我是否真的从相机中取出这些像素? 例如,我可以指定 3840 x 2160 并获得该大小的视频帧!
考虑到这些不同的分辨率设置,是否有系统的方法可以评估/确定相机的真实分辨率或有效分辨率? 下面是一些 Python/OpenCV 代码来演示。
import numpy as np
import cv2, cv
import time
cap = cv2.VideoCapture(0) # note you may need to pass 1 instead of 0 into this to get your camera
cap.set(3,3840) #horizontal pixels
cap.set(4,2160) #vertical pixels
cap.set(5, 15) #frame rate
time.sleep(2) #trying to solve a delay issue ... never mind this
#acquire the video from the camera
while(cap.isOpened()):
ret, frame = cap.read()
cv2.imshow("captured video", frame)
if cv2.waitKey(33) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
import cv2
cam = cv2.VideoCapture(0)
w = cam.get(cv2.CAP_PROP_FRAME_WIDTH)
h = cam.get(cv2.CAP_PROP_FRAME_HEIGHT)
print(w, h)
while cam.isOpened():
err, img = cam.read()
cv2.imshow("lalala", img)
k = cv2.waitKey(10) & 0xff
if k == 27:
break
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.