Ask Your Question
0

How to disable autofocus of a webcam on Windows 10? [closed]

asked 2019-04-09 05:29:24 -0600

ZubenkoMikhail gravatar image

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.

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

I have tried:

  1. Unofficial pre-built OpenCV packages for Python: opencv-contrib-python https://pypi.org/project/opencv-contr...
  2. build from source opencv 3.4.3 with MSMF, VFW, DSHOW backends
  3. build from source opencv 4.1 with MSMF, DSHOW backends

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

Code that I use https://github.com/opencv/opencv/blob...

I use the following code to specify backend VideoCapture(0 + BACKEND_ID) where BACKEND_ID is taken from here

https://docs.opencv.org/3.4.3/d4/d15/...

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by ZubenkoMikhail
close date 2019-04-10 04:41:26.738290

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-04-09 05:49:55 -0600

mshabunin gravatar image

Try to use VideoCapture(0, cv.CAP_MSMF) constructor. I've tried this sample with modified constructor and cap.set(cv.CAP_PROP_AUTOFOCUS, False) returned True for BRIO 4K.

I've found that focus values should have range 0-100 (even maybe 0-255?) for this camera/backend, so you will need to change v/100 to v when setting focus property.

edit flag offensive delete link more

Comments

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

ZubenkoMikhail gravatar imageZubenkoMikhail ( 2019-04-10 04:40:58 -0600 )edit

Are you able to get 4k resolution on Windows? At what fps? Can you change the FOV angle?

Witek gravatar imageWitek ( 2019-04-10 18:19:59 -0600 )edit

I've been able to get 4096x2160 and 3840x2160 at 30 FPS. Camera is connected via USB3.

Though there are two black bars on sides and actual image has 4:3 aspect ratio. Logitech Camera Settings can change mode to "Widescreen" but it got reset each time I run LCS and this setting does not affect my app. Looks like all 16:9 resolutions have black bars (e.g. 1280x720), 4:3 don't (800x600).

Don't know how to set FOV in OpenCV, I can change it in Logitech Camera Settings and it keeps that when I run my app.

mshabunin gravatar imagemshabunin ( 2019-04-11 04:26:24 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2019-04-09 05:29:24 -0600

Seen: 5,794 times

Last updated: Apr 09 '19