相关疑难解决方法(0)

在OpenCV/Python中设置相机参数

我正在使用OpenCV(2.4)和Python(2.7.3)以及Thorlabs的USB摄像头(DC1545M).

我正在对视频流进行一些图像分析,我希望能够从我的视频流中更改一些摄像机参数.令人困惑的是,我能够改变一些相机属性而不是所有相机属性,我不确定我做错了什么.

这是代码,使用Python中的cv2绑定,我可以确认它运行:

import cv2


#capture from camera at location 0
cap = cv2.VideoCapture(0)
#set the width and height, and UNSUCCESSFULLY set the exposure time
cap.set(3,1280)
cap.set(4,1024)
cap.set(15, 0.1)

while True:
    ret, img = cap.read()
    cv2.imshow("input", img)
    #cv2.imshow("thresholded", imgray*thresh2)

    key = cv2.waitKey(10)
    if key == 27:
        break


cv2.destroyAllWindows() 
cv2.VideoCapture(0).release()
Run Code Online (Sandbox Code Playgroud)

作为参考,cap.set()命令中的第一个参数引用了相机属性的枚举,如下所示:

0. CV_CAP_PROP_POS_MSEC Current position of the video file in milliseconds.
1. CV_CAP_PROP_POS_FRAMES 0-based index of the frame to be decoded/captured next.
2. CV_CAP_PROP_POS_AVI_RATIO Relative position of the video …
Run Code Online (Sandbox Code Playgroud)

python camera opencv python-2.7

77
推荐指数
5
解决办法
19万
查看次数

标签 统计

camera ×1

opencv ×1

python ×1

python-2.7 ×1