rogor
Posts: 1
Joined: Sun Feb 14, 2016 4:02 pm

Camera to video_render, how to save one image on demand ?

Sun Feb 14, 2016 4:23 pm

Hello everyone!

I currently have a program which uses the camera, video_render and resize component, along with OpenGLES and egl_render. The goal is to display the fullHD feed on the main HDMI screen (the video_render component), and display a second smaller feed on the 7" touchscreen (with the egl_render component) on which we can then run face detection with OpenCV.

Basically, the component chain is like this :
camera (preview port 70) -> video_render (full HD)
camera (capture port 71) -> resize -> egl_render

Everything is working fine, but what I now need is a way to save an image in fullHD on demand. Basically a function which when called, would save the currently displayed image on the video_render (or the next image, it doesn't really matter) to a file.

I don't really know the best way to do this. Should I try to use the port 72 of the camera (apparently used to capture still images). Can I just intercept the buffer going into the video_render and save it somehow ? Is there an even simpler way ?

Thanks!

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6196
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Camera to video_render, how to save one image on demand

Sun Feb 14, 2016 9:17 pm

video_splitter is your friend.
OMX_IndexConfigBrcmBufferFlagFilter: 251, 252, 253, 254
Allows an output port to request that only buffers where the buffer
flags match any or all of the specified buffer flags are forwarded.
Default is 0xFFFFFFFF to allow all buffers through. 0x0 will allow no
buffers through.
video_splitter supports that on all the output ports, so you can configure

Code: Select all

camera : 70 -> 250 : video_splitter : 251 -> video_render
                                    : 252 -> client
Set OMX_IndexConfigBrcmBufferFlagFilter to 0x0 by default.
When you want a frame, change it to either OMX_BUFFERFLAG_ENDOFFRAME (or 0xFFFFFFFF to play really safe) to grab the next frame.
This approach also allows you to ask for a different image format to the one sent to video_render as it will do a conversion when necessary.

If you really want the current frame on the display, you could look at vc_dispmanx_snapshot (https://github.com/raspberrypi/userland ... anx.h#L127)
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “OpenMAX”