gordon77
Posts: 8057
Joined: Sun Aug 05, 2012 3:12 pm

Arducam 16MP AF camera on a Pi5 ?

Sun Nov 26, 2023 11:05 am

Using BOOKWORM.

If I add dtoverlay=imx519 to /boot/config.txt on a Pi4 the camera will be found by libcamera-still --list-cameras

but on a Pi5 it won't. Also tried it in /boot/firmware/config.txt

Anyway to get this to work ?

( Please don't just tell me to ask Arducam, or use their version of Libcamera apps :D )

therealdavidp
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1076
Joined: Tue Jan 07, 2020 9:15 am

Re: Arducam 16MP AF camera on a Pi5 ?

Mon Nov 27, 2023 10:07 am

I think all the correct code and drivers for a Pi 5 are in place (they're unchanged from Pi 4, in fact), it's just the tuning file for the new ISP that needs to be made. You could verify this by copying one of the other tuning files to "imx519.json" and seeing if the camera starts (even though it will look horrid).

If you had Macbeth chart, a range of light sources, and one of those diffuse video LED lights, you could follow the instructions in chapter 6 of the tuning guide. We'd be happy to help anyone who wants to have a go through the process.

gordon77
Posts: 8057
Joined: Sun Aug 05, 2012 3:12 pm

Re: Arducam 16MP AF camera on a Pi5 ?

Mon Nov 27, 2023 10:25 am

copied imx519.json to /usr/share/libcamera/ipa/rpi/pisp still no luck.

copied contents of imx219.json to imx519.json still no luck

therealdavidp
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1076
Joined: Tue Jan 07, 2020 9:15 am

Re: Arducam 16MP AF camera on a Pi5 ?

Mon Nov 27, 2023 11:15 am

Which file did you copy to imx519.json? It needs to be a PiSP format tuning file, such as one already in /usr/share/libcamera/ipa/rpi/pisp. Or if you're using libcamera-hello, you could probably run something like "LIBCAMERA_RPI_TUNING_FILE=/usr/share/libcamera/ipa/rpi/pisp/imx219.json libcamera-hello"

gordon77
Posts: 8057
Joined: Sun Aug 05, 2012 3:12 pm

Re: Arducam 16MP AF camera on a Pi5 ?

Mon Nov 27, 2023 11:24 am

therealdavidp wrote:
Mon Nov 27, 2023 11:15 am
Which file did you copy to imx519.json? It needs to be a PiSP format tuning file, such as one already in /usr/share/libcamera/ipa/rpi/pisp. Or if you're using libcamera-hello, you could probably run something like "LIBCAMERA_RPI_TUNING_FILE=/usr/share/libcamera/ipa/rpi/pisp/imx219.json libcamera-hello"
I copied the on in /usr/share/libcamera/ipa/rpi/vc4 which was wrong !

used imx219.json in usr/share/libcamera/ipa/rpi/pisp
Last edited by gordon77 on Tue Nov 28, 2023 9:41 am, edited 1 time in total.

therealdavidp
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1076
Joined: Tue Jan 07, 2020 9:15 am

Re: Arducam 16MP AF camera on a Pi5 ?

Mon Nov 27, 2023 12:00 pm

And you still have "dtoverlay=imx519" in your config.txt? (Third party cameras do not get auto-detected)

It might be interesting to see if the camera is recognised correctly ("dmesg | grep imx") and the output of libcamera-hello.

gordon77
Posts: 8057
Joined: Sun Aug 05, 2012 3:12 pm

Re: Arducam 16MP AF camera on a Pi5 ?

Mon Nov 27, 2023 12:43 pm

I finally got it to work !

In config.txt

Disable auto_camera_detection

Add
dtoverlay=imx519,cam0
dtoverlay=imx219,cam1

I have 2 cameras attached.

naushir
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 433
Joined: Mon Apr 25, 2016 10:21 am

Re: Arducam 16MP AF camera on a Pi5 ?

Tue Nov 28, 2023 8:40 am

This webpage suggests Arducam have added support for their cameras on Pi 5. Not sure what tree their changes live in though.

gordon77
Posts: 8057
Joined: Sun Aug 05, 2012 3:12 pm

Re: Arducam 16MP AF camera on a Pi5 ?

Tue Nov 28, 2023 9:00 am

Thanks for the info.

Looks promising but for me if it involves having to use their version of libcamera/rpicam then l will stick to my method of using the pi rpicam version and living with manual focus and my python very slow AF. :D

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 15922
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Arducam 16MP AF camera on a Pi5 ?

Tue Nov 28, 2023 3:55 pm

naushir wrote:
Tue Nov 28, 2023 8:40 am
This webpage suggests Arducam have added support for their cameras on Pi 5. Not sure what tree their changes live in though.
https://github.com/ArduCAM/libcamera/bl ... mx519.json

https://github.com/ArduCAM/libcamera/co ... d0ac33dd1c adds their tuning files for pisp.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

gordon77
Posts: 8057
Joined: Sun Aug 05, 2012 3:12 pm

Re: Arducam 16MP AF camera on a Pi5 ?

Tue Nov 28, 2023 5:06 pm

Excellent, thanks :D

I notice since installing this imx519.json the AF works BUT I can't set manual focus.

I use to use os.system("v4l2-ctl -d /dev/v4l-subdev" + str(foc_sub5) + " -c focus_absolute=" + str(focus))
where foc_sub5 is the number required for the camera and focus a number between 0 and 4096 as defined in the ctrls-list.

Do you think the AF can be stopped to allow this manual focus ?

therealdavidp
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1076
Joined: Tue Jan 07, 2020 9:15 am

Re: Arducam 16MP AF camera on a Pi5 ?

Tue Nov 28, 2023 5:45 pm

You should be able to comment out the autofocus algorithm in the tuning file. Find where it says "rpi.af" and change it to (for example) "x.rpi.af" which should cause it to be silently ignored.

gordon77
Posts: 8057
Joined: Sun Aug 05, 2012 3:12 pm

Re: Arducam 16MP AF camera on a Pi5 ?

Tue Nov 28, 2023 6:00 pm

therealdavidp wrote:
Tue Nov 28, 2023 5:45 pm
You should be able to comment out the autofocus algorithm in the tuning file. Find where it says "rpi.af" and change it to (for example) "x.rpi.af" which should cause it to be silently ignored.
Thanks, that sounds permanent, l'd like to be able to switch on /off to allow manual.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 15922
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Arducam 16MP AF camera on a Pi5 ?

Tue Nov 28, 2023 6:26 pm

Why not just add "-lens-position 1" added to rpicam-[hello|still|vid]? Yes it's in units of diopters instead of the absolute register value, but that's part of why libcamera is there to normalise controls.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

gordon77
Posts: 8057
Joined: Sun Aug 05, 2012 3:12 pm

Re: Arducam 16MP AF camera on a Pi5 ?

Tue Nov 28, 2023 6:51 pm

6by9 wrote:
Tue Nov 28, 2023 6:26 pm
Why not just add "-lens-position 1" added to rpicam-[hello|still|vid]? Yes it's in units of diopters instead of the absolute register value, but that's part of why libcamera is there to normalise controls.
Thanks l'll try that.

gordon77
Posts: 8057
Joined: Sun Aug 05, 2012 3:12 pm

Re: Arducam 16MP AF camera on a Pi5 ?

Wed Nov 29, 2023 10:32 am

Thanks for all the help with this.

I tried --lens-position but I need to rerstart rpicam every time, which isn't really practical when using 'manual' focussing. 'Manual' focusing is not adjusting the lens by hand but setting it to a fixed position through software.

I solved it with making a copy of imx519.json with the rpi-af section disabled, and saved it as imx519mf.json and used --tuning file to call it when needed. Works great on a Pi5 :D

I can now switch between 2 cameras, eg Pi v3 and Arducam 16MP and control both in AF or manual focus.

User avatar
scruss
Posts: 5734
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON

Re: Arducam 16MP AF camera on a Pi5 ?

Wed Nov 29, 2023 3:10 pm

gordon77 wrote:
Mon Nov 27, 2023 12:43 pm
In config.txt

Disable auto_camera_detection
This is what Arducam seem to recommend with all of their hardware now.

It's certainly the case with their ultra-wide fixed-focus IMX708 M12 120° module
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

gordon77
Posts: 8057
Joined: Sun Aug 05, 2012 3:12 pm

Re: Arducam 16MP AF camera on a Pi5 ?

Wed Nov 29, 2023 3:12 pm

scruss wrote:
Wed Nov 29, 2023 3:10 pm
gordon77 wrote:
Mon Nov 27, 2023 12:43 pm
In config.txt

Disable auto_camera_detection
This is what Arducam seem to recommend with all of their hardware now.

It's certainly the case with their ultra-wide fixed-focus IMX708 M12 120° module
A pity they can't get their cameras included in Auto detection, but l am not sure who is responsible for that.

swe
Posts: 131
Joined: Sun Apr 24, 2022 10:52 am
Location: Switzerland

Re: Arducam 16MP AF camera on a Pi5 ?

Sun Jan 21, 2024 3:46 pm

therealdavidp wrote:
Mon Nov 27, 2023 11:15 am
you could probably run something like "LIBCAMERA_RPI_TUNING_FILE=/usr/share/libcamera/ipa/rpi/pisp/imx219.json libcamera-hello
Downloaded both imx219. json and also img519-json form here: https://github.com/ArduCAM/libcamera/tr ... /pisp/data and moved them to /usr/share/libcamera/ipa/rpi/pisp
I've tried this in a terminal

Code: Select all

swe@raspi5:~ $ LIBCAMERA_RPI_TUNING_FILE=/usr/share/libcamera/ipa/rpi/pisp/imx219.json libcamera-hello
[0:12:25.376437014] [2042] ERROR IPAModule ipa_module.cpp:172 Symbol ipaModuleInfo not found
[0:12:25.376486626] [2042] ERROR IPAModule ipa_module.cpp:292 v4l2-compat.so: IPA module has no valid info
[0:12:25.376532200] [2042]  INFO Camera camera_manager.cpp:284 libcamera v0.1.0+118-563cd78e
Preview window unavailable
ERROR: *** no cameras available ***
and this

Code: Select all

swe@raspi5:~ $ LIBCAMERA_RPI_TUNING_FILE=/usr/share/libcamera/ipa/rpi/pisp/imx519.json libcamera-hello
[0:13:39.860927778] [2047] ERROR IPAModule ipa_module.cpp:172 Symbol ipaModuleInfo not found
[0:13:39.860960038] [2047] ERROR IPAModule ipa_module.cpp:292 v4l2-compat.so: IPA module has no valid info
[0:13:39.860998204] [2047]  INFO Camera camera_manager.cpp:284 libcamera v0.1.0+118-563cd78e
Preview window unavailable
ERROR: *** no cameras available ***
I believe that imx519 would be correct.

gordon77
Posts: 8057
Joined: Sun Aug 05, 2012 3:12 pm

Re: Arducam 16MP AF camera on a Pi5 ?

Sun Jan 21, 2024 3:51 pm

Did you modify config.txt ?

Disable auto_camera_detection

Add
dtoverlay=imx519,cam0
dtoverlay=imx219,cam1

swe
Posts: 131
Joined: Sun Apr 24, 2022 10:52 am
Location: Switzerland

Re: Arducam 16MP AF camera on a Pi5 ?

Mon Jan 22, 2024 8:27 am

gordon77 wrote:
Sun Jan 21, 2024 3:51 pm
Did you modify config.txt ?

Disable auto_camera_detection

Add
dtoverlay=imx519,cam0
dtoverlay=imx219,cam1
Only one16MP camera is connected. I have certainly made the entry dtoverlay=imx519 and deactivated the entry camera_auto_detect=1.

gordon77
Posts: 8057
Joined: Sun Aug 05, 2012 3:12 pm

Re: Arducam 16MP AF camera on a Pi5 ?

Mon Jan 22, 2024 12:27 pm

Try dtoverlay=imx519,cam0

I read somewhere that cam1 is default, not sure if that applies here

swe
Posts: 131
Joined: Sun Apr 24, 2022 10:52 am
Location: Switzerland

Re: Arducam 16MP AF camera on a Pi5 ?

Mon Jan 22, 2024 1:31 pm

gordon77 wrote:
Mon Jan 22, 2024 12:27 pm
Try dtoverlay=imx519,cam0

I read somewhere that cam1 is default, not sure if that applies here
Great, that did it. Thanks

swe
Posts: 131
Joined: Sun Apr 24, 2022 10:52 am
Location: Switzerland

Re: Arducam 16MP AF camera on a Pi5 ?

Fri Jan 26, 2024 11:20 am

gordon77 wrote:
Wed Nov 29, 2023 10:32 am
used --tuning file to call it when needed. Works great on a Pi5 :D
What's that?

gordon77
Posts: 8057
Joined: Sun Aug 05, 2012 3:12 pm

Re: Arducam 16MP AF camera on a Pi5 ?

Fri Jan 26, 2024 12:07 pm

swe wrote:
Fri Jan 26, 2024 11:20 am
gordon77 wrote:
Wed Nov 29, 2023 10:32 am
used --tuning file to call it when needed. Works great on a Pi5 :D
What's that?
When running the rpicam apps you can specify a tuning file. I used the 'normal ' arducam one and made a mf version ( see back in this thread) and used them when appropriate when using rpicam-vid etc.

Here's a bit of code from my rpicamgui.py...

Code: Select all

if (Pi_Cam == 5 or Pi_Cam == 6) and foc_man == 1 and Pi == 5:
        if os.path.exists('/usr/share/libcamera/ipa/rpi/pisp/imx519mf.json'):
            datastr += " --tuning-file /usr/share/libcamera/ipa/rpi/pisp/imx519mf.json"   
It adds the tuning file to the rpicam-vid command when using a arducam camera set in Manual focus, on a Pi5

https://github.com/Gordon999/RPiCamGUI
Attachments
screenshot.jpg
screenshot.jpg (57.6 KiB) Viewed 613 times

Return to “Camera board”