IMX519 focus problem

  1. Where did you get the camera module(s)?

  2. Model number of the product(s)?

  3. What hardware/platform were you working on?
    raspberry pi 4 2gb

  4. Instructions you have followed. (link/manual/etc.)

  5. Problems you were having?
    I can’t find a system to manually set the focus in a script

  6. The dmesg log from your hardware?

  7. Troubleshooting attempts you’ve made?
    I have a script that does a timelapse.
    /usr/local/bin/libcamera-still -t 61200000 -o %05d.jpg --timelapse 7000 --immediate 1
    I had initially tried giving --continue-autofocus but the result is not acceptable.
    rebooting the raspberry or for other random reasons the focus shifts
    a solution would be to put
    /usr/local/bin/libcamera-still -n -o test.jpg --autofocus
    as the first instruction but at night when the timelapse starts there is no light and no good focus

  8. What help do you need?
    Is there a possibility to focus via script a certain area of the image manually?
    For example if the value 0 corresponds to the minimum distance and 100 corresponds to infinity give via script a focus = 75
    or is there a possibility to force the focus to infinity?

hi, @ugone

You can manually focus as follows:

Step 1. Install the focus adjustment software

git clone

Step 2. Open a preview window

libcamera-still -t 0

Step 3. Use our focus adjustment tool

cd Arducam-Pivariety-V4L2-Driver/focus
python3 -d /dev/v4l-subdev1

Step 4. Press the Up/Down Arrow for focus adjustment, press “ctrl + c” to save, or “r” to


Good morning and thank you for your response. Yes it is a good system but it is not a solution because it assumes c’io have access to the raspberry. To do the first tests it is obviously not a problem but when it is operational the PI with the camera has neither internet nor possibility to access via ssh.
I was hoping there was a system once I found the ideal focus value to be able to put the command directly into the script
Thanks again

Do you mean you want to control the focus manually. Such as by switch ?
At present, we just have this script, I suggest you use another program to call this
script to realize control by another application.
In this way, If the application can start automaticly, you don’t need to access the script via the ssh.

Okay I’ll try this route. Thank you