Eli Bridge
Eli Bridge

Reputation: 11

Seeking a simple way to display an image on an RPi and continue python execution

I'm transferring an application to an RPi, and I need a way to display full screen images using python (3) while code continues to execute. I would like to avoid delving into complicated GUI modules like Tkinter and Pygame. I just want images to fill the screen and stay there until the code replaces them or tells them to go away. If Tkinter or Pygame can do this, that would be fine, but it looks to me like they both enter loops that eventually require keyboard input. My application involves montiring sensors and external inputs, but there will be no keyboard attached. I've tried the following:

feh activated with subprocess.call (This displays the image, but the code stops executing until the image is cleared by a keystroke.

wand.display (this works but only shows a smallish window, not full screen)

fbi (couldn't get it to display an image)

xcd-open (works but opens in "Image Viewer" app in small window - no option for full screen without a mouse click)

I have not tried OpenCV. Seems like that might work, but that's a lot of infrastructure to bring in for this simple application.

For the record I've been to google and have put many hours into this. This request is a last resort.

If you want some pseudocode:

displayImage("/image_folder/image1.jpg" fullscreen = True)
time.sleep(1)
clearImage()
displayImage("/image_folder/image2.jpg" fullscreen = True)

Upvotes: 1

Views: 2220

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207405

You don't show how you tried with feh and a subprocess, but maybe try starting it in the background so it doesn't block your main thread:

subprocess.call("feh -F yourImage.jpg &", shell=True)

Note that background processes, i.e. those started with &, are using a feature of the shell, so I have set shell=True.

Then, before you display the next image, kill the previous instance:

subprocess.call("pkill feh")

Alternatively, if you know the names of all the images you plan to display in advance, you could start feh in "Slideshow mode" (by passing in all the image names on startup), and then deliver signal SIGUSR1 each time you want to advance the image:

os.kill(os.getpid(...), signal.SIGUSR1)

If the above doesn't work, please click edit under your original question and add in the output from the following commands so we can go down the framebuffer route:

fbset -fb /dev/fb0

tvservice -d edid
edidparser edid

Upvotes: 2

Related Questions