0

I'm working on a graphical application, made for console mode, and facing some performance issues when working with large resolution (1920px wide here).

One part of the display, a video background, is generated and displayed via pygame (SDL 1.2 python bindings).
The other part of the display, the UI, is also generated with pygame, but is displayed as a GPU overlay (based on the dispmanx API : https://github.com/AndrewFromMelbourne/raspidmx), via a fork of pngview, launched as a subprocess.

Here is the detailled steps and timings :
- UI image is generated on a pygame Surface. (take 0.03s)
- Pygame surface is converted to a (x,y,4) int8 array, representing the RGBA array. (also take 0.03s) layerRGBA = np.fromstring(layerUI.get_buffer().raw,np.uint8).reshape(resX,resY, 4)
- The pixel array is then written to a memory mapped file (take 0.03s too)
fp = np.memmap("/tmp/layerRGBA.raw",dtype='int8', mode='w+', shape=(resX,resY,4)) fp[:] = res
- Then the subprocess is told to refresh the UI via a stdin message. (take 0.00s)

Can I expect to achieve better performance on the conversion or mmap part ? Or is there a faster way to communicate this RGBA layer from my main python app to my dispmanx C program than mmap?

Thank you for your suggestions !

  • top I'm actually trying to do the same thing where I want to overlay some images over my omxplayer video in python. Can you share your code or experience with me? I'm rather new to Linux and Python. Thank you! – ydylwj23 Jun 22 '18 at 0:38
  • The easiest solution would be to launch multiple pngview session on different layers. See github.com/AndrewFromMelbourne/raspi2png – Technico.top Jun 25 '18 at 10:04
  • oops, read raspi2png instead of pngview ^^" – Technico.top Jun 25 '18 at 12:43
0

Found it : mmal is slightly faster than mmap.

Refer to the picamera module, overlay section, for a real-world implementation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.