nieks
Posts: 27
Joined: Tue Oct 11, 2022 1:53 pm

Overlay drawing on frame(s) using MMAL

Thu Dec 22, 2022 11:01 am

Hi all,


As some of you know I am working on a project to show a camera feed on screen and also save it on disk at the same time.
I have done several tests using gstreamer, ffmpeg and also a modified "yavta" version from 6by9. It looks like for our purposes we'd prefer working with MMAL directly as done in 6by9's example.

What I can't figure out from the (limited) MMAL documentation, is the preferred way to draw overlays on top of the UYVY camera feed coming in. What we want is some simple info (like the current date, time, and other small texts) but ALSO some graphics like battery icons and other status icons. We'd prefer to have these assats saved as PNG's (including transparent background) and plot these on top of the video feed, including transparency and with a sem-transparent background bar (like half-grey).

I have found this:
https://github.com/t-moe/rpi_mmal_examp ... ode.c#L121
But that ain't working. It looks like this is build for other image types (RBG?) than the images I have.

Where can I find more documentation on how to build overlays (and perhaps other tricks) using MMAL ?

Note I am new to image/camera/video programming, but I do have experience with C(++).
We're still in the R&D phase of our project; so we are still flexible on stuff like programming language, although just by looking at the experience of our development team we'd prefer C or C++.

Any pointers ?

User avatar
Gavinmc42
Posts: 7308
Joined: Wed Aug 28, 2013 3:31 am

Re: Overlay drawing on frame(s) using MMAL

Thu Dec 22, 2022 11:17 am

Search for HermannSW posts I think he does this sort of stuff.
viewtopic.php?p=1930038&hilit=Crosshairs#p1930038

I have done it with OpenVG but that won't work on the VC6 Pi4's.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

nieks
Posts: 27
Joined: Tue Oct 11, 2022 1:53 pm

Re: Overlay drawing on frame(s) using MMAL

Thu Jan 26, 2023 5:00 pm

Gavinmc42 wrote:
Thu Dec 22, 2022 11:17 am
Search for HermannSW posts I think he does this sort of stuff.
viewtopic.php?p=1930038&hilit=Crosshairs#p1930038

I have done it with OpenVG but that won't work on the VC6 Pi4's.
Thanks. I checked out those posts and samples but still have difficulty. Also can't find real good documentation on how to use MMAL.
Are there any "hidden docs" or something? I can see there are some overlay features in MMAL, but can't find the specs.

User avatar
HermannSW
Posts: 5783
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Overlay drawing on frame(s) using MMAL

Thu Jan 26, 2023 10:26 pm

No MMAL, no doc, but lots of C code using dispmanx ...
https://github.com/AndrewFromMelbourne/raspidmx
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://github.com/Hermann-SW/RSA_numbers_factored
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

nieks
Posts: 27
Joined: Tue Oct 11, 2022 1:53 pm

Re: Overlay drawing on frame(s) using MMAL

Fri Jan 27, 2023 1:18 pm

HermannSW wrote:
Thu Jan 26, 2023 10:26 pm
No MMAL, no doc, but lots of C code using dispmanx ...
https://github.com/AndrewFromMelbourne/raspidmx
Using an old/outdated version of libpng :-(

User avatar
AndyD
Posts: 2342
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia

Re: Overlay drawing on frame(s) using MMAL

Sat Jan 28, 2023 7:14 am

Hi, I am the author of that code.
nieks wrote:
Fri Jan 27, 2023 1:18 pm
Using an old/outdated version of libpng :-(
Not necessarily. That README.md file is 8 years old. The instructions were correct at that time. There is nothing in the code that requires an old or outdated version of libpng.

However, the Raspberry Pi has moved on. The DIspmanX API is deprecated.
jamesh wrote: dispmanx is indeed deprecated. You will need to revert to FKMS or the earlier graphics system to get dispmanx back.

Or move to DRM.
I have moved on to DRM/KMS and I hope to port some of my DispmanX examples to DRM/KMS. It is on my very long list of projects.

User avatar
HermannSW
Posts: 5783
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Overlay drawing on frame(s) using MMAL

Sat Jan 28, 2023 5:28 pm

Even at times long ago where I did not program in Python (currently I do for some projects, like RSA_numbers_factored.py in 1st signature link), I used sometimes picamera (Python) to play with overlays. Compared to dispmanx all was so much easier to do.

Recently I created Overlays for showing (640x150 and) 640x75 areas in 640x480 camera preview for @csoffa for correctly positioning v2 camera for capturing 640x75@1007fps with raspiraw (he uses that for capturing moving golf ball, below frames are 1ms apart):
viewtopic.php?t=345368&hilit=csoffa#p2070489
Image
Image
Image

I created two gists for him, one with new picamera2 based on new libcamera stack
https://gist.github.com/Hermann-SW/3360 ... d09b2038f5

and one with picamera on legacy camera stack:
https://gist.github.com/Hermann-SW/ec96 ... 5f2c6e666b

Given that camera overlays (with alpha blending!) are so easy to do with picamera[2], you might want to consider using picamera as well:
(the overlay is the same, but below is life camera preview window)
picam2.overlay.jpg
picam2.overlay.jpg
picam2.overlay.jpg (38.28 KiB) Viewed 730 times
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://github.com/Hermann-SW/RSA_numbers_factored
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

nieks
Posts: 27
Joined: Tue Oct 11, 2022 1:53 pm

Re: Overlay drawing on frame(s) using MMAL

Tue Feb 07, 2023 10:30 am

Thanks! I will take a look at that.

Return to “C/C++”