Search code examples
pythonimagesegmentation-faultgtkpygtk

GTK segfault reading an ndarray


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?


Solution

  • 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.