1、环境

个人使用的是golang语言通过gocv库来使用opencv。其它语言通过opencv来使用摄像头的接口的函数和参数一致,此文也可作参考。

gocv地址:

https://github.com/hybridgroup/gocv

2、曝光设置

opencv通过VideoCapture的Set方法来设置曝光参数等其它摄像头参数。

webcam, _ := gocv.OpenVideoCapture(0)

webcam.Set(gocv.VideoCaptureExposure,-5)

如果opencv设置曝光无效,可以通过VideoCaptureAutoExposure参数设置自动曝光为手动曝光。

webcam.Set(gocv.VideoCaptureAutoExposure,0.25)

这个0.25官方是这样说明的,就是手动曝光:

where 0.25 means "manual exposure, manual iris"

3、曝光参数具体对应于曝光时间

CaptureExposure值曝光时间
-1640 ms
-2320ms
-3160ms
-480ms
-540 ms
-620ms
-710ms
-85ms
-92.5ms
-101.25ms
-11650 µs
-12312 µs
-13150µs

注:参数过多次,一般设置完手动曝光之后,无法不重启的情况下,设置回自动曝光。