Red edge shading remains on Arducam 8MP PTZ IMX219 Pi 5; need tuning guide

Hi all, hoping someone can point me in the right direction. I’ve got an Arducam 8MP Pan Tilt Zoom camera (IMX219 sensor) on a Raspberry Pi 5, and I’m trying to run lens shading calibration, but the camera won’t register at all. Running libcamera-still just reports “no cameras available”.

This is what I ran from ~/Desktop/IMP_2:

libcamera-still -t 0 --tuning-file imx219_original.json

Full output:

[1:37:59.766435291] [3488] INFO Camera camera_manager.cpp:313 libcamera v0.3.0+65-6ddd79b5
[1:37:59.774464094] [3491] INFO RPI pisp.cpp:695 libpisp version v1.0.6 b567f0455680 17-06-2024 (10:20:00)
[1:37:59.785515023] [3491] WARN RPiSdn sdn.cpp:40 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise
[1:37:59.785904448] [3491] ERROR IPARPI pisp.cpp:275 Tuning data file target returned “bcm2835”, expected “pisp”
[1:37:59.785917467] [3491] ERROR RPI pipeline_base.cpp:798 Failed to load a suitable IPA library
[1:37:59.785924448] [3491] ERROR RPI pisp.cpp:922 Failed to register camera imx219 4-0010: -22
Made X/EGL preview window
ERROR: *** no cameras available ***

The sensor is detected as imx219 4-0010, so the hardware seems to be present, but libcamera just won’t bring it up. Anyone seen this before?

The important line in that log is:

ERROR IPARPI pisp.cpp:275 Tuning data file target returned “bcm2835”, expected “pisp”

That means your tuning file imx219_original.json was written for the legacy bcm2835 ISP. The Raspberry Pi 5 uses the newer PiSP pipeline, and its IPA expects the tuning data to declare target “pisp”. Because the target doesn’t match, the IPA library fails to load (that’s the pipeline_base.cpp:798 error), and then camera registration fails with -22, which is why you get “no cameras available”.

So the camera hardware is probably fine - it’s the tuning file that’s wrong for the Pi 5. Where did imx219_original.json come from? It looks like it was built for an older Pi.

It came with the camera materials I got for the PTZ board. I hadn’t realised tuning files were ISP-specific. Is there a Pi 5 version of the tuning file for this sensor, or do I need to convert this one somehow?

You need a tuning file whose target is “pisp”. I’ve sent you a Pi 5-compatible tuning file, imx219_120d.json, via private message - please check your messages.

Once you have it, place it in /home/pi and run:

libcamera-still -t 0 --tuning-file imx219_120d.json

Keep -t 0 for now just to confirm the camera comes up. Let me know if it registers this time.

That worked - the camera now registers and I can capture. Thanks! I also use the PTZ Python demo for this camera. How do I make it load the same tuning file? At the moment the demo initializes the camera itself.

Good to hear. For the PTZ demo, open RpiCamera.py (it’s in the PTZ-Camera-Controller folder). Find this line:

self.cam = Picamera2()

Change it to:

self.cam = Picamera2(tuning=“/home/pi/imx219_120d.json”)

Save the file, then run FocuserExample.py again and see if everything behaves.

I made the change and FocuserExample.py runs fine now. The image is noticeably better than before, but I still see a slight red shading toward the edges. Is there a way to tune that out manually? I’d like to fine-tune the lens shading myself rather than just live with it.

The remaining red shading on the edges is lens shading that can be adjusted in the tuning file itself. The official Raspberry Pi Camera Guide covers this - have a look at chapter 6, which goes through camera tuning:

Chapter 6 walks through the tuning process and how to adjust the lens shading tables manually, which is what you’d tweak for the residual red edges.

So to sum up: the original failure was the bcm2835 vs pisp tuning target mismatch on the Pi 5, imx219_120d.json fixes registration and gives a better image, and the remaining edge shading can be fine-tuned following chapter 6 of the guide.