Dual 64MP cameras on Raspberry Pi CM4: multi-camera, RAM, libcamera, AF, crop questions

Hi all, I’m building a custom C++ application to control a pair of 64MP cameras on a Raspberry Pi CM4 and I’ve got a pile of open questions I can’t really find answers to. Quick background on the setup:

  • 2x 64MP camera for Raspberry Pi (Arducam)
  • Raspberry Pi CM4 module (two CSI-2 inputs)
  • I’ve installed the modified libcamera-dev and libcamera-apps
  • Writing my own C++ app on top of it

Things I’m trying to figure out:

  1. Is it actually possible to connect two 64MP cameras to the two CSI-2 inputs of the CM4? I know the connectors physically line up but I have no idea if the driver/ISP side handles it.
  2. Would a 2GB RAM CM4 be enough to get viewfinder/video stream from both cameras at once, and still capture 64MP stills one by one? Or am I going to run out of memory?
  3. I installed the modified libcamera-dev and libcamera-apps but I cannot find the source of the modified libcamera anywhere. Can someone point me in the right direction so I can reference the implementation?
  4. For long-distance capture, would it work to set AF to infinity at startup and just leave it there? I expect I’d need to calibrate each camera individually to find the infinity position — would that position be stable across camera restarts?
  5. I want to request zoomed/cropped parts of the image, with the crop position potentially changing between frames (basically a zoomed tracking frame). Is it possible to request a different crop/scale per frame? And would new crop settings apply to the very next captured frame without any delay?

I think that last one is what the modified libcamera is doing, so I’m hoping the libcamera-apps source will help me understand how to control the camera. Any pointers appreciated.

Hi, happy to help work through these. Let me take them in order.

  1. Two 64MP cameras on the two CSI-2 inputs of a CM4 — yes, this is doable. We’ve managed to get a pair running that way.

  2. Regarding RAM: honestly 2GB is going to be tight for this use case. I’d suggest going with a 4GB or 8GB CM4 module instead. You’re holding two viewfinder/video streams plus a full 64MP still capture, and that adds up quickly.

  3. On the source — the modified libcamera source is not different from the official one in terms of the code you’d read for this. It’s open source, so just refer to the official libcamera source upstream. Nothing hidden there.

  4. Manual focus is supported, so setting infinity at startup is workable — you just enter the command manually to set the focus position. Worth doing your per-camera calibration to find the infinity point.

  5. On the crop/zoom side: what was implemented in the modified libcamera is digital zoom only. Compared to the official libcamera, the changes are just ISP adjustments to support that. Per-frame crop/scale with the position changing between frames is not something I can point you at as an existing implementation.

Start with the RAM situation — what size module are you actually on right now?

Thanks, that helps a lot. Let me go through it.

So for #5, are you saying the digital zoom is applied at the ISP level, on the Pi side, rather than by reconfiguring the sensor? That’s kind of the crux of what I want to understand. If it’s all ISP-side, then the crop can’t move faster than whatever the ISP can process, right?

For the manual focus — could you give me the actual form of the command? I want to make sure I’m setting the lens position correctly rather than just guessing at a value. And for the infinity calibration, is the position you find once going to hold after a power cycle of the camera, or does it drift and need re-calibrating every time?

On the RAM: I’m on a 2GB module right now. Sounds like I should be looking at 4GB at minimum. But before I go buy another module, is there any rough guidance on what 2GB will and won’t handle? Like, can it do the two streams and just choke on the stills, or does it fall over on the streaming alone?

Yeah, the digital zoom is ISP-side — the modifications in the modified libcamera are ISP adjustments relative to the official build, not sensor reconfiguration. So the crop is effectively a scaled/cropped region of what the ISP gives you, applied after the sensor has produced the frame.

For manual focus, you set the lens position with the focus control and enter the command manually to place it — it’s command-driven, not auto. For the infinity-calibration stability across restarts, I don’t want to over-promise: the right approach is to calibrate each camera individually and find the infinity position per module, then re-check it after a restart. Lens-to-lens and mounting variation is exactly why it’s per-camera.

On RAM, I’d rather steer you straight: for this use case (two 64MP sensors plus 64MP stills) we recommend 4GB or 8GB. The 2GB module isn’t the right fit here.

Ok, I followed up on the crop control now that I understand the mental model, and I’ve got some new results plus a new problem.

First the good news: I found that controls::ScalerCrop can be set without restarting the camera, and the actual ROI is returned for every CompletedRequest. That’s exactly what I needed — no camera restart per crop change. The Python example for controlling focus was also really helpful, thanks for that.

Now the problem. When I zoom in, the image quality at lower resolutions looks really bad compared to higher resolutions. I’m running the camera through libcamera and using controls::ScalerCrop. Resolutions I’ve tested:

  • 2312x1736 @ 30fps
  • 4624x3472
  • 9152x6944

A zoomed-in crop at 2312x1736 @ 30fps is visibly much worse than the same zoomed view at 4624x3472 or 9152x6944. It’s not just softness, it looks like I’m losing detail that should be there.

So questions:

  1. Is the digital zoom processing always done on the RPi side (the ISP), regardless of the resolution I request?
  2. What I really want is lower resolution + higher frame rate, and then a digital zoom with an ROI request on top — is that achievable without the quality collapse I’m seeing?
  3. Is it possible to stream the lower resolution but have the sensor actually configured to capture at the higher resolution, from the smaller area controlled by the ROI? I.e. crop in the sensor, not just the ISP.
  4. Would the update rate be limited by the sensor resolution, or by the stream from the camera to the Pi?

Great to hear the per-frame controls::ScalerCrop path works for you — that’s the intended way to move the ROI without restarting.

On the quality drop, here’s what’s happening based on what you’re describing. The digital zoom is applied on the Pi/ISP side, so when you pick 2312x1736 you’ve already told the sensor+ISP to give you a smaller source image. Cropping into that smaller image and scaling it back up magnifies the reduced detail — you’re essentially zooming into fewer real pixels. At 4624x3472 or 9152x6944 the crop has far more source pixels behind it, so the same zoom holds up much better. That’s consistent with what you’re seeing.

So to answer your points:

  1. Yes — digital zoom here is Pi/ISP-side.
  2. Lower resolution at higher frame rate plus an ROI zoom is exactly the trade-off you’re hitting: the lower the source resolution, the less real detail the zoom has to work with.
  3. What you’re asking there — streaming a lower resolution while the sensor captures a higher resolution from the ROI area (a sensor-level crop, not an ISP-level one) — is not what this implementation does. The modified libcamera only does the ISP adjustments for digital zoom; there’s no per-frame sensor crop/scale path referenced in it.
  4. Practically, both matter: the achievable update rate is limited by whichever is slower — the sensor’s readout/output of the resolution you configured, or the stream link from the camera to the Pi.

So the short version: you can move the ROI per frame without a restart, but the detail you can zoom into is bounded by the resolution you configure the sensor/stream at. If you need sharper zoomed output, you need a higher configured resolution, and that’s what will cap your frame rate. If you want the lower-res high-fps stream and sharp zoom simultaneously, that requires sensor-side cropping of a high-res readout, which isn’t implemented in the modified libcamera — I don’t have a workaround for that in the current build. If that’s a hard requirement for the project, let me know and we can look at what’s realistic, but don’t want to promise something the current stack can’t do.