Manual RasPi Camera v3 webcam auto focus?

Camera model

Raspberry Pi camera Module 3

What is the problem?

Everything works perfectly. The version 3 offers auto focus. I notice the camera constantly auto focusing. Is there a plugin or other way to turn off auto focus and manually set the focus? I see a plugin for Arducam, but I am not sure if this would control other webcams as well.

What did you already try to solve it?

I assume if I set I2C to 0, auto focus would be disabled, but I would still need to have a way to manually focus the camera

Have you tried running in safe mode?

Did running in safe mode solve the problem?

Systeminfo Bundle

octoprint-systeminfo-20230720131708.zip (1.3 MB)

WRITE HERE

Additional information about your setup

OctoPi 1.0.0, OctoPrint 1.9.2, E3V2, RapsPi camera v3

1 Like

You have to adjust the configuration in /boot/camera-streamer/libcamera.conf file. See below:

I wrote this previously when working out how to do it:

You can definitely turn off autofocus by using

OPTIONS='--camera-options="AfMode=0"

The closest explanation I could find of the values was the Raspberry Pi documentation - which doesn't use the same values. It does list some AF modes, but with no numbers attached. Source.

I believe it is:

  • 0: 'manual' focus - allows to use LensPosition
  • 1: 'auto' focus - auto focus once when the camera starts up
  • 2: 'continuous' AF - what the default is in this image - continuously adjusts the focus to try and keep the image sharp.

I then played around with LensPosition in the same way as autofocus, eg.

OPTIONS='--camera-options="AfMode=0" --camera-options="LensPosition=1"

and could set the different values between 0 and 32 and it changed the focal point a lot. Focus scales aren't really linear, so you might not need 16, so I suspect trial and error might help. Alternatively, use AFMode=1 to autofocus once.

2 Likes

Thank you! I'll try this out right now.

Thanks this helped!