0

我正在寻找一种将多个 numpy 数组(图像)转换为字节的有效方法,以便我可以将它们显示到 GUI 中,在我的例子中是来自https://github.com/pyimgui/pyimgui的 imgui 。

我这样做的方式似乎有点违反直觉,因为我从神经网络获取图像,并且我需要逐帧转换以显示在渲染引擎中。管道是:

get z vector -> 
generate image data from the z vector -> 
convert the image data to PIL image -> 
.convert("RGB") the PIL image -> 
get the PIL image in bytes using : data = im.tobytes("raw", "RGBA", 0, -1)

这对我来说似乎效率极低,我同时对 5 个纹理执行此操作(来自两个不同的神经网络)。即使当我尝试直接在 OpenGL 上下文中显示 PIL 图像甚至 numpy 数组而不是字节时,我也只会看到一个故障。

任何帮助表示赞赏。

4

0 回答 0