Need example of picamera2 preview code for Arducam HAT kit IMX477 camera array

Hey everyone, I’ve got an Arducam HAT kit with an array of IMX477 cameras and I’m trying to write a camera preview in picamera2. I can’t find any documentation that shows how to write preview code for this specific HAT array setup. I tried following the generic picamera2 docs but it didn’t work for my setup. Has anyone got a working example for this hardware?

Could you give a bit more detail about your setup? Are you using the Arducam multi-camera HAT with several IMX477 modules on a single Pi? And when you say the generic picamera2 docs didn’t work, what happened exactly — no preview window, an exception, or the cameras not being listed? The basic preview flow in picamera2 is Picamera2() → create_preview_configuration() → configure() → start(), so knowing where it breaks would help narrow things down.

Right, it’s the HAT kit with an array of IMX477 cameras. I followed the standard picamera2 preview example, but it seems to assume a single camera. With the HAT array I’m not sure which camera it’s actually opening or how to target a specific one. The docs I found don’t mention the multi-camera HAT case at all, so I got stuck pretty quickly.

Got it. That matches what I’d expect — the generic Picamera2 documentation mainly covers single-camera setups and doesn’t get into the Arducam multi-camera HAT array specifics. For the preview code itself, start with the official Raspberry Pi preview example: picamera2/examples/preview.py at main · raspberrypi/picamera2 · GitHub. Then cross-reference the Arducam PiCamera2 user guide for the HAT array details like camera selection/indexing and tuning files: Picamera2 User Guide - Arducam Wiki. Those two together should give you the correct preview usage for your hardware.

Thanks. So just to confirm — the preview.py example is the base for the preview code, and the Arducam guide is where I’ll find the array-specific parts like choosing which camera on the HAT? The generic docs just never covered that part for me.

Exactly. The Raspberry Pi preview.py example is the recommended reference for how to write the preview loop in picamera2, and the Arducam PiCamera2 user guide covers the parts that are specific to the Arducam HAT kit array of IMX477 cameras. That combination is the current recommendation — the generic Picamera2 docs alone won’t cover the multi-camera HAT setup, which is why it didn’t work for you as-is.