简体   繁体   中英

Is it possible to disable autofocus of a webcam on Windows 10?

I am working with python opencv and I am not able to disable autofocus, autoexposure etc on windows 10.

I am using Logitech BRIO 4k webcam.

Everything works perfectly on Ubuntu 18.04. With Opencv 3.4.4 using v4l backend I am able to set focus, exposure, video resolution successfully. However the same code doesn't work on windows

on windows I have tried:

  1. Unofficial pre-built OpenCV packages for Python: opencv-contrib-python https://pypi.org/project/opencv-contrib-python/

  2. build from source opencv 3.4.3 with MSMF, VFW, DSHOW backends. With VFW I am not able to open video capture at all

  3. build from source opencv 4.1 with MSMF, DSHOW backends

in every case above (except VFW backend) I am able to use opencv functionality, read and show frames from a webcam, but not able to disable autofocus.

code that I use from official opencv GitHub repo https://github.com/opencv/opencv/blob/master/samples/python/video_v4l2.py

I create video capture like so to specify backend VideoCapture(0 + BACKEND_ID) where BACKEND_ID is taken from here https://docs.opencv.org/3.4.3/d4/d15/group__videoio__flags__base.html

Environmental variable OPENCV_VIDEOIO_DEBUG=True confirms that I use particular backend

Questions on the same topic without answers Disable webcam's autofocus in Windows using opencv-python

cap.set( cv.CAP_PROP_SETTINGS, 1 ); doesn't work on both windows and linux

Since the code works on linux I believe that the problem is in the videoio backend. Can you suggest some other backend or maybe v4l analog on windows that opencv supports.

Forgot to mention, I was using virtual box to run on windows. If I run the same code on windows machine directly everything works)) Must be some problem with virtual box

The only difference is that focus values seem to be in range 0-255. But in the sample code I provided above they are in 0-100 range

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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