There is an API for the Raspberry Pi called DispmanX that allows you to add layers that are displayed over other layers.  It seems the API isn't documented but as far as we know everything on the Raspberry Pi display is a DispmanX layer.  So this means you can use it to do things like overlay images on top of say the camera live stream, another application, etc.

Resources

https://jan.newmarch.name/RPi/Dispmanx/

Setting which layer applications should use

Some applications will allow you to specify the layer they should use.

pngview

By default the pngview program adds a black background (on layer 0) to obscure the framebuffer. Use -b 0 to make this layer transparent instead. The new parameter -l specifies which DispmanX layer to display the image on. PNG file transparency is handled correctly

./pngview -b 0 -l 3 /usr/share/raspberrypi-artwork/raspberry-pi-logo-small.png

omxplayer

Use layer 2:

omxplayer –layer 2 /opt/vc/src/hello_pi/hello_video/test.h264

Examples

Place an image over raspvid

./pngview -b 0 -l 3 my_overlay_image.png &		#Transparent background (-b), Layer 3 (-l)
raspivid -t 0

killall pngview #Use this to close the pngview afterwards

 

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published. Required fields are marked *