How to get clear images from webcam in movement with Python?

Hey guys!

Is it possible to get very sharp images from a webcam capture?

When the objects I want to detect in the image are stopped, the sharpness is excellent, but when the objects are in motion, the frames captured by opencv are not so sharp.

I’ve already tried to change some parameters of the Logitech c920 HD 1080p camera such as:

v4l2-ctl -d /dev/video2 --set-ctrl=exposure_auto_priority=0
v4l2-ctl -d /dev/video2 --set-ctrl=exposure_auto=3
v4l2-ctl -d /dev/video2 --set-ctrl=focus_auto=0
v4l2-ctl -d /dev/video2 --set-ctrl=focus_absolute=50
v4l2-ctl -d /dev/video2 --set-ctrl=sharpness=255

Although the captured images have gotten better, they’re still not as sharp as I’d like.

Is it possible to improve this?

I will attach some examples below.

Stopped:

On movement:
image

tldr: LOTS of light

motion blur is proportional to exposure time. literally. from the speed of the object and the exposure time, you can calculate the amount of motion blur.

image quality (signal/noise) is proportional to the amount of light per exposure.

lower exposure time, for the same picture quality, requires the same light to be squeezed into less time. that generally means more intense light.

more intense light could be implemented as flashing light. literally like a camera flash, except 30/60/whatever times a second. professional/industrial camera lighting is timed to the camera’s exposure (or the camera is triggered by a signal coinciding with the flash). that kind of input/output is not available for webcams.

for a random webcam, just get stronger light.

in the c920, you can adjust exposure time. it might be called “shutter speed”, or not.

“exposure” can be the product of exposure time and “gain”, i.e. multiplying the signal (and the noise).


oh and make sure the light isn’t behind the camera, but to the side of it. your background reflects that light… and you don’t want that. the way you’re lighting this right now ruins everything.


related: opencv - How to get clear images from webcam in movement with Python? - Stack Overflow

1 Like

Hi, @crackwitz , thanks for suggestions!

I’ll try to add more light and check exposure and gain parameters.

Hi @crackwitz !

I followed your suggestion and add max light possible combining with lower expose and some another camera parameters changes and got very nice results!

Bellow are my new camera parameter configuration:
image

And the new results bellow:

Thanks for your help!