小编Hol*_*ler的帖子

在Kivy中显示一个numpy数组

首先,我对kivy全新,所以我有点挣扎.

我正试图在一个kivy窗口中显示一个numpy数组.到目前为止,我发现这应该使用Texture Class(http://kivy.org/docs/api-kivy.graphics.texture.html).

由于我的numpy数组不时更改,我正在尝试将以下代码调整到我的应用程序.

# create a 64x64 texture, defaults to rgb / ubyte
texture = Texture.create(size=(64, 64))

# create 64x64 rgb tab, and fill with values from 0 to 255
# we'll have a gradient from black to white
size = 64 * 64 * 3
buf = [int(x * 255 / size) for x in range(size)]

# then, convert the array to a ubyte string
buf = b''.join(map(chr, buf))

# then blit the buffer
texture.blit_buffer(buf, colorfmt='rgb', …
Run Code Online (Sandbox Code Playgroud)

arrays textures numpy kivy

7
推荐指数
1
解决办法
4503
查看次数

标签 统计

arrays ×1

kivy ×1

numpy ×1

textures ×1