Update image in same window with, say, PIL

J

John O'Hagan

I'm using something like the following to display an image and refresh
it in the same window each time the image file is updated:

import cv

def display(filename):
"""Display scores as they are created"""
cv.NamedWindow(filename)
while 1:
... #wait for signal that filename has been updated,
#or to break
image = cv.LoadImage(filename)
cv.ShowImage(filename, image)
cv.WaitKey(1000)


I would like to do the same thing using PIL, for two reasons. First,
the main project is written in Python 3, but cv is only available in
Python 2, so I have to launch the above as a separate process and do
IPC with it, which is annoying; whereas PIL has recently come into
Python 3. Second, PIL seems like a more appropriate tool. CV is a
sophisticated computer-vision project which I happen to be more
familiar with, but I'm using it just to display an image, so I feel as
if I'm using the Mars Explorer to vacuum my apartment.

I have found a couple of StackOverflow and ActiveState recipes to do
this but they all seem to involve great globs of windowing code
involving Tkinter or Qt, which I know nothing about. CV does seem to
magically manage the windowing. Can I do this equally simply with PIL,
or perhaps something else in Python 3?

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top