I’ve got an application that converts OpenCV’s IplImages to Tkinter images in a display loop. Naturally, I want to do this is the most efficient way possible to increase the app’s responsiveness.
Here’s how I’m currently doing it (frame is the IplImage):
pil_image = PIL.Image.fromstring(
'RGB',
cv.GetSize(frame),
frame.tostring(),
'raw',
'BGR',
frame.width*3,
0)
tk_image = ImageTk.PhotoImage(pil_image)
So it’s converting the entire OpenCV image to a string, feeding it through PIL, and then converting from PIL to TK. Is there a better way?
I couldn’t find a better way to do it, so I refactored my application to use
highguito display the OpenCV images. It forces me to use an extra window and an extra thread (one for Tkinter GUI for the application widgets, and one for highgui), but at least this way the application is more responsive.