First of all, I'm completely new to kivy, so I'm struggling a bit.
I am trying to display a numpy array in a kivy window. So far, I realized that this should work using the Texture class ( http://kivy.org/docs/api-kivy.graphics.texture.html ).
As my numpy array changes from time to time, I'm trying to set up the following code for my application.
It seems that creating the texture and changing it works as it should, but I don't get how to display the texture.
Can someone explain me how to use
with self.canvas: Rectangle(texture=texture, pos=self.pos, size=(64, 64))
in a way, what I get to see my / numpy image array.
Thanks in advance! Holzroller
Edit: I realized that using Kivy 1.8.0 and Texture Class is a bit messy. So I upgraded to Kivy 1.9.0 via github (installing Kivy via apt-get on Ubuntu 14.04 LTS serves you version 1.8.0), and I can see Texture using the following code. Hope this helps people who have the same problem as me.
from kivy.graphics.texture import Texture from kivy.graphics import Rectangle from kivy.uix.widget import Widget from kivy.base import runTouchApp from array import array from kivy.core.window import Window
Edit2: Basically, I returned to the original problem: I have a numpy array (type 'numpy.ndarray'; dtype 'uint8') and I'm trying to convert it to a format so that the texture will show me the image. I tried to break it in the same way as in the above code example. But I, unfortunately, do not work. I really don't know what I'm doing wrong here. (my numpy matrix is ββcalled im2 in the folling code)
list1 = numpy.array(im2).reshape(-1,).tolist() arr = array('B', list1) texture.blit_buffer(arr, colorfmt='rgb', bufferfmt='ubyte')