Random capture timeout capturing consecutive images with Arducam OV9281 MIPI on Raspberry Pi 3B

Hi everyone, I’ve written a lot of code using the MIPI library and it’s working great except for one random connection issue. Can anyone tell me how to reset the camera, or how to get out of this state?

What I’m doing: I modified the capture_raw.c example so it takes consecutive images as fast as possible - basically calling save_image in a loop with no delay - because I need to run calculations on successive images. The camera responds at over 120fps, which is great.

The problem: when I run this program longer than 10 seconds, I occasionally get ‘capture timeout’. What is happening to the camera? And more importantly, how can I reset the camera on the fly from inside the program, without having to restart it?

Some background on how I got here: I couldn’t get the camera working with my Raspberry Pi 3. At section 1 of the docs the device OV9281 wasn’t even listed, and after part #2 the screen just froze with nothing printed. While struggling to get it working I also got ‘VIDIOC_STREAMON returned -1 (Invalid argument)’, and running libcamera-hello produced a host of errors. When I ran the two libcamera commands I got a pop-up screen that was all gray - no image at all.

Welcome! Let’s dig into this. A few things I need to know before I can point you in the right direction:

  1. Which Pi model exactly, and which OS are you running (full version)?
  2. Which camera module is it?
  3. Are you using the arducam_mipicamera library/examples, or libcamera?

Also, the ‘VIDIOC_STREAMON returned -1 (Invalid argument)’ error usually means the driver isn’t loaded or the right overlay isn’t in config.txt. Can you paste the exact commands you ran when you got the gray screen?

Sure. Here’s my setup:

  • Raspberry Pi 3B
  • Legacy OS for the Pi 3B (this is what finally got the camera working)
  • I was on Raspbian Bullseye 11 before and that was the source of a lot of frustration
  • Using the arducam_mipicamera libraries and examples (modified) - working pretty well now
  • Camera: Arducam OV9281 1MP Global Shutter Monochrome NoIR Camera for Raspberry Pi (MIPI)
  • I’m also using an Arducam 5MP Plus OV5642 Mini Module Camera Shield SPI with an ESP8266 and Teensy 4.1

One odd thing: in this OS version there is NO camera option in ‘Preferences / Raspberry Pi Configuration / Interfaces…’. I only see SSH/VNC/SPI/I2C/Serial Port/Serial Console/1-Wire/Remote GPIO. No camera entry at all.

That missing camera entry is expected on newer OS builds - it just means the camera stack changed. Let’s make sure the overlay and autodetect settings are right first.

Open config.txt:

sudo nano /boot/config.txt

Add these lines (and make sure they’re exactly like this):

dtoverlay=ov9281
camera_auto_detect=0

The camera_auto_detect=0 line is important - it disables the auto-detection so your explicit overlay takes over. Then reboot:

sudo reboot

After it comes back, try:

libcamera-still -t 0

That’s just a preview. If that shows an image, we’re on the right track.

OK I added dtoverlay=ov9281 to the end of config.txt and set camera_auto_detect=0, then rebooted.

Still no good. libcamera-still -t 0 gives me the gray pop-up window again with no image. I also ran the ‘video’ and ‘capture’ apps inside MIPI_Camera/RPI and both give me the same error as before.

And libcamera-still -t 5000 -o test.jpg also just produces a gray image. Any idea what’s going on? I feel like I’ve tried everything.

Alright, let’s update the libcamera stack itself - an older libcamera build can cause exactly that gray/no-image behavior. Run these in order:

wget -O install_pivariety_pkgs.sh https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/install_pivariety_pkgs.sh
chmod +x install_pivariety_pkgs.sh
./install_pivariety_pkgs.sh -p libcamera_dev
./install_pivariety_pkgs.sh -p libcamera_apps

Then give it another try:

libcamera-still -t 0 # preview
libcamera-still -t 5000 -o test.jpg # save a picture

Let me know what happens after the update.

Did the update with those commands. Still gray preview and gray test.jpg.

I also disabled legacy camera in raspi-config in case that was conflicting, and rebooted. No change.

I checked the hardware too - measured Ground to VCC on the board and it reads 3.3 Volts, so the cable seems to be installed properly. The camera just doesn’t seem to want to come up.

Is there anything else I can check? I’ve been fighting this for a while.

Good, at least we’ve confirmed wiring and power. For the Pi 3 hardware specifically, there’s a known display/GL issue that can cause the gray preview. Try this:

sudo raspi-config

Then navigate: 6. Advanced Options → A8 Glamor → enable it. Reboot your Pi and try accessing the camera again with the libcamera command.

If it’s still failing after that, we need real diagnostics. Please run the bug report script - it bundles everything I need to see:

Enabled Glamor and rebooted, still the same gray screen.

So I ran the bug report script:

wget -O arducam-camera-bug-report https://github.com/ketai-dhr/arducam-camera-bug-report/releases/download/tools/arducam-camera-bug-report
chmod +x ./arducam-camera-bug-report
./arducam-camera-bug-report

It generated an arducam-camera-bug-report.txt in the current directory. I’ve got that plus some logs from earlier (log11-07-22.txt) and my config.txt and os-release if those help.

I’d really like to get this moving - could we do a call to speed this up? I’m available late at night too if that works better.

Thanks, that report is what I need. Also, rather than back-and-forth over the thread, I’ve sent you the remote support details privately - please check your messages and we can dig in together.

One quick note while you check that: from your logs, one earlier capture took around 110-140ms, which works out to roughly 9-7 fps. That’s worth keeping in mind because it tells me how the driver is behaving under your capture path.

Go ahead and send over the bug report contents and we’ll go from there.

Sent it over. But here’s the thing - I actually got the camera working now! I installed the Legacy OS for the Raspberry Pi 3B and that did it. With the arducam_mipicamera libraries and examples (after some modification) it’s working pretty well.

So I’m back to my original problem. I modified the capture_raw.c example to take consecutive images as fast as possible by calling save_image in a loop with no delay. It hits over 120fps. But when I run it longer than about 10 seconds, I occasionally get ‘capture timeout’ again.

What’s happening to the camera when that happens, and how do I reset it on the fly without restarting the whole program?

Glad you got it running on the Legacy OS. Now, an important thing you should know: the MIPI library you’re using is no longer supported on our side, so there’s only limited advice I can give you for that specific library. The arducam_mipicamera path is essentially legacy now.

The bigger picture: Raspberry Pi is updating its OS and phasing out Buster, which means the camera driver has to move forward along with the Pi OS. That’s part of why you saw all those libcamera errors and gray previews earlier - the driver and OS were out of sync.

Let me summarize where things stand for the capture timeout issue.

Here’s the summary of what we’ve established:

Root cause / findings:

  • The MIPI library is no longer supported by Arducam, so only limited guidance is possible for that library.
  • The Raspberry Pi OS is being updated and Buster is being phased out - the camera driver needs to be updated in line with the newer Pi OS.
  • The intermittent ‘capture timeout’ shows up specifically when capturing consecutive raw images continuously for more than ~10 seconds at high frame rate (>120fps). This is a limitation of that old MIPI driver path under sustained raw capture, not something you can reliably reset from inside the running program.

What works today (your current setup):

  • Legacy OS for the Raspberry Pi 3B
  • Self-modified arducam_mipicamera examples, with capture_raw.c changed to loop save_image with no delay
  • This reaches over 120fps but intermittently hits ‘capture timeout’ after ~10 seconds of continuous capture.

Recommended path forward:

  • Move to the newer recommended Arducam OV9281 MIPI camera module and update the camera driver in line with the newer Raspberry Pi OS (since Buster is being weeded out). The OV9281 MIPI camera module (1MP monochrome global shutter) is a good choice here: Arducam OV9281 1MP Global Shutter Monochrome NoIR Camera Module with M12 Mount lens for Raspberry Pi 4/3B+/3
  • For the current OS, the install steps we used (install_pivariety_pkgs.sh -p libcamera_dev / -p libcamera_apps, then libcamera-still -t 0 and libcamera-still -t 5000 -o test.jpg) are the right approach once the driver matches the OS.

If the Pi ever looks locked up during testing, just reboot and we’ll continue from there. I’ve also left the reference doc for OV9281 with the userland MIPI driver linked above. Let me know if you want to go the newer-module route and I’ll walk you through the driver update.