0

I have several images from a live feed in a buffer and I want to display the images using GTK in Python. Basically, I was thinking of using a while loop that gets the latest frame in the buffer. But then I can't figure out how to show this in GTK.

The images are read using OpenCV, which creates an ndarray. Using

GdkPixbuf.Pixbuf.new_from_data(image, GdkPixbuf.Colorspace.RGB, False, 8, width, height, width*3) 

I get a segfault. Any idea what goes wrong?

Cassie
  • 362
  • 4
  • 15
  • I'd expect your code to raise [`TypeError: new_from_data () takes Exactly 9 arguments (7 given)`](http://stackoverflow.com/questions/10341988/converting-pil-gdkpixbuf) if you're using GTK3 - a little confused... [This](http://stackoverflow.com/questions/29501835/gtk3-gdk-pixbuf-new-from-data-gives-segmentation-fault-core-dumped-error-13) has same error, but no answer. You might try [`new_from_bytes`](https://developer.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-bytes). Can you post `type(image)`, `image.shape`, `type(image[0][0])` ? – J Richard Snape Oct 08 '15 at 14:10
  • Thanks for the insights! The format of the image was incorrect. I got a 2D array, but expected an RGB-array. A different problem has surfaced though. The image displayed by the GUI is not what I expect. – Cassie Oct 09 '15 at 09:23

1 Answers1

0

I found the solution. By filling the PixBuf differently, I could get the image I expected. The solution was found at Converting PIL Image to GTK Pixbuf. It is the second answer.

Community
  • 1
  • 1
Cassie
  • 362
  • 4
  • 15