Read Focus from Arducam 64mp in Python with Picamera2

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

  2. Model number of the product(s)?
    64mp arducam

  3. What hardware/platform were you working on?

  4. Instructions you have followed. (link/manual/etc.)
    manual and then troubleshooting the forum

  5. Problems you were having?
    Reading the current focus level that was previously set by autofocus

  6. The dmesg log from your hardware?

  7. Troubleshooting attempts you’ve made?

  8. What help do you need?
    Hi! It seems like RPi has been updating things that have been breaking things, and yall have been doing a good job scrambling to update your versions of the libcamera picamera2 libraries for the Arducam 64

One thing i needed for a problem I am working on with the Arducam is that I want to be able to READ what the current focus the camera gets set to. After lots of troubleshooting (and ddisable_touchscreen=1
in the config.txt) i got the camera working and can manually set the focus using the LensPosition control in python.

BUT i want to be able to READ what the current focus the camera had been set to before was (especially after an autofocus) so that I could do things like increment the focus slightly toward or away from what it had been focused to.

I noticed when I did a printout of the metadata there is nothing i can poll about the lensposition or focus.

Is there a call i can make to the controls to READ the focus level? Thanks!

At the present time, I am sorry to tell you that we do not have an off-the-shelf function for your requirement. :sweat:
But your idea is interesting, maybe we will try to do it when we have spare time.

1 Like

ah too bad. Is there a way to read what the focus is from like a libcamera call?

(or something else i can run from my python script to just see what the focus is? Because somehow the focuser example is reading the focus the camera is at, right?)

Is there any update on the subject? It would be really useful to be able to read the focus position.


1 Like

yes! i cracked it!

I finally figured out how to READ the focus. (at least on the command line)


you have to read the diopter value!

%lp Diopter of the current lens (1/distance in meters)

a command to do this is like
libcamera-still -t 0 --autofocus-mode auto --info-text "focus %focus diopter %lp"

note that %focus just tells you HOW focused an image is, not the actual focus value

That’s great! Thank you very much :grinning:
Do you know if the diopter value that you get is the same used in picam2.set_controls({“AfMode”: 0, “LensPosition”:0}) as the LensPosition value?
I’m referring to this page Picamera2 - Arducam Wiki
Thanks again!

1 Like

i believe so. it seems to be numbers in the same exact range.

1 Like