Camera Focus made Easy

Did quite a bit of research on turning off auto focus but this makes it easier for people that just need brass tax.

Open SSH to your Raspberry Pi, I like MobaXTerm (if you haven't used it, your welcome :slight_smile:

With autofocus on, set your camera up where you want it.

sudo v4l2-ctl --get-ctrl=focus_absolute

--This tells you what your focus is at, it's important for the third command.

sudo v4l2-ctl --set-ctrl=focus_auto=0
sudo v4l2-ctl --set-ctrl=focus_absolute=##number from first command##

Next you have to write it to your startup or it will be written over on reboot.

sudo nano home/pi/mpeg-streamer/start.sh

right under their explanation of the file, put in your commands, here are mine.

sudo v4l2-ctl --set-ctrl=focus_auto=0
sudo v4l2-ctl --set-ctrl=focus_absolute=380

Hit crtl+x to save document
yup
yup

Done.

1 Like

How do i do this with a docker installation?

First run docker ps to see the running containers and to get the CONTAINER_ID. Then run docker exec -it {CONTAINER_ID} /bin/bash where {CONTAINER_ID} is that from the previous step. That will get you to a bash shell, in your container.

That said, I'm getting "unknown control 'focus_absolute'" on the current docker image when I try absolute_focus. I did find more info (that led me to finding I don't have that control on my current camera) at: Reddit - Dive into anything

After this print, I'm also going to checkout: Camera Settings