Stop video stream on detection and take a HQ image

I’m building an app that uses the rpi camera to scan for birds. I have using the example hailo-apps and made use of yolo to detect birds. What I’d like to do is stop the video pipeline and use the picamera2 api to take a high quality still image each time a bird is detected in frame. Once the picture has been taken, I would like to restart the pipeline.

Note: I already have tried simply saving the frame (and even cropping the frame to the identified bird). However I want to use the entire sensor to capture a high quality image instead of using the video stream.

I’m using a raspberry pi 5 with the Hailo Pi Hat 2 (Hailo-10H).

Hi @user920,

I would suggest the following:
Stop pipeline → picamera2 still → restart pipeline.
Don’t do it from inside a GStreamer probe (deadlock) rather set a flag and handle it from a separate thread.

# On bird detection (from another thread, not the probe):
pipeline.set_state(Gst.State.NULL)
time.sleep(0.5)

picam2 = Picamera2()
picam2.configure(picam2.create_still_configuration(main={"size": picam2.sensor_resolution}))
picam2.start(); time.sleep(1)
picam2.capture_file(f"bird_{int(time.time())}.jpg")
picam2.stop(); picam2.close()

pipeline.set_state(Gst.State.PLAYING)

Add a cooldown (e.g. 5s) to avoid rapid stop/start cycles.

Thanks,

Thank you for the response. I had based my initial ideas on the detection example creating my own app_callback class. Would you have a recommendation for where I should read up in the developer documentation to understand the best way to get a handle on the executing pipeline?

Hi,

Maybe this will be helpful? hailo-apps/doc/developer_guide/app_development.md at main · hailo-ai/hailo-apps · GitHub

Thanks,