Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8041

Camera board • Re: Fast image capture with Raspberry Camera V3 NoIR

$
0
0
I was wondering if there's a way to do this with rpicam-still. It has a "--signal" option so you could run rpicam-still in the background as a server, and have your client send it a signal whenever you want a capture. Then rpicam-still would write to an output file, which could be a Linux fifo, and your client would read until EOF.

But I think this is still a bit sub-optimal as rpicam-still will switch from preview to capture mode each time, making even 2fps tricky.

I might just write a Python server to perform the same function, but without the mode switching. Like so:

Code:

import osimport signalimport timefrom picamera2 import Picamera2def handler(signum, frame):    picam2.capture_file("fifo.jpg")signal.signal(signal.SIGUSR1, handler)picam2 = Picamera2()config = picam2.create_still_configuration(buffer_count=3)picam2.start(config)print("Pass the server pid to client:", os.getpid())while True:    time.sleep(1)
The client could be in C, C++ or anything you like. In Python you might make the fifo, then run this (passing it the server pid):

Code:

import ioimport osimport sysimport signalpid = int(sys.argv[1])  # pass in the pid printed out by the serverwhile True:    input("Press enter to capture...")    output = io.BytesIO()    os.kill(pid, signal.SIGUSR1)    with open("fifo.jpg", 'rb') as fifo:        while (data := fifo.read()):            output.write(data)    print("Received", len(output.getvalue()), "bytes")
In this case I've passed a JPEG encoded image, but you could pass a PNG, or a BMP or any data format of your own. You will easily achieve way more than 2fps.

Statistics: Posted by therealdavidp — Wed Dec 17, 2025 4:08 pm



Viewing all articles
Browse latest Browse all 8041

Trending Articles