Tuesday, 15 January 2013

python - Raspberry Pi Camera Transparent Image Overlay -


Is it possible to overlay a transparent (PNG or GIF) image on a PI camera preview?

I've got some code but it creates a white background

  import pikamera from PIL import import from time to gold. With Pikamera As Camera Camera () Camera: camera.start_preview () # Load an image of arbitrary size Img = Image.open ('lol.gif') # # Mode 'RGB' pad = Image. Create a solid picture in the required size with New ('RGB', ((((img.size [0] + 31) ./32) * 32, ((img.size [1] + 15) 16/16) * 16 ,) # Paste the original image into # padded pad.paste (img, (0, 0)) # Add the image with the mattress overlay as the source, # But the dimensions of the original image are o = camera.add.overlay (pad. ), Size = IMG size = # is in the overlay # preview by default, which is below # preview (which is the default for layer 2) Here we make #new overlays semi-transparent, Then call it #Olfa = 255 o Move from top to layer = 3 Wait indefinitely until the user does not end the script unless true: sleep (1)   from 'RGB'  to  'Rgba'  

/ P>

I do not have a situation to investigate it, but I think your Will fix the problem.


No comments:

Post a Comment