【问题标题】:Kivy Image displays nothing for some jpg images对于某些 jpg 图像,Kivy Image 不显示任何内容
【发布时间】:2019-12-24 07:56:17
【问题描述】:

我有一个简单的 Kivy 应用程序,可以从目录中一张一张地加载图像。运行应用程序时,某些 jpg 图像无法在 Raspberry Pi 3 上显示。当应用程序从 Mac 运行时,所有图像都可以正常显示。

我能够确定 jpg 图像之间的唯一区别是颜色配置文件(sRGB 失败,P3 有效)。虽然这可能是一个红鲱鱼。

我已尝试将图像渲染更改为可用的。默认渲染器是 SDL2。我也试过ffpy和PIL。

这是我的 Kivy 日志:

[INFO   ] Logger: Record log in /root/.kivy/logs/kivy_19-12-23_0.txt
[WARNING] [Config      ] Upgrading configuration in progress.
[WARNING] [Config      ] Older configuration version detected (0 instead of 21)
[INFO   ] Kivy: v1.11.1
[INFO   ] Kivy: Installed at "/usr/local/lib/python3.7/dist-packages/kivy/__init__.py"
[INFO   ] Python: v3.7.3 (default, Apr  3 2019, 05:39:12) 
[GCC 8.3.0]
[INFO   ] Python: Interpreter at "/usr/bin/python3"
[INFO   ] Factory: 184 symbols loaded
[INFO   ] ImageLoaderFFPy: Using ffpyplayer 4.3.0
[INFO   ] Image: Providers: img_tex, img_dds, img_sdl2, img_pil, img_ffpyplayer, img_gif 
[DEBUG  ] App: Loading kv <./carousel.kv>
[DEBUG  ] App: kv <./carousel.kv> not found
[DEBUG  ] Window: Ignored <egl_rpi> (import error)
[INFO   ] Window: Provider: sdl2(['window_egl_rpi'] ignored)
[INFO   ] GL: Using the "OpenGL" graphics system
[INFO   ] GL: Backend used <sdl2>
[INFO   ] GL: OpenGL version <b'OpenGL ES 2.0'>
[INFO   ] GL: OpenGL vendor <b'Broadcom'>
[INFO   ] GL: OpenGL renderer <b'VideoCore IV HW'>
[INFO   ] GL: OpenGL parsed version: 2, 0
[INFO   ] GL: Shading version <b'OpenGL ES GLSL ES 1.00'>
[INFO   ] GL: Texture max size <2048>
[INFO   ] GL: Texture max units <8>
[DEBUG  ] Shader: Fragment compiled successfully
[DEBUG  ] Shader: Vertex compiled successfully
[DEBUG  ] ImageSDL2: Load </usr/local/lib/python3.7/dist-packages/kivy/data/glsl/default.png>
[INFO   ] Window: auto add sdl2 input provider
[INFO   ] Window: virtual keyboard not allowed, single mode, not docked
[DEBUG  ] Cache: register <kv.loader> with limit=500, timeout=60
[INFO   ] Loader: using a thread pool of 2 workers
[DEBUG  ] ImagePIL: Load </usr/local/lib/python3.7/dist-packages/kivy/data/images/image-loading.gif>
[DEBUG  ] Base: Create provider from mouse
[DEBUG  ] Base: Create provider from probesysfs
[DEBUG  ] ProbeSysfs: using probesysfs!
[DEBUG  ] ProbeSysfs: found device: FT5406 memory based driver at /dev/input/event0
[INFO   ] ProbeSysfs: device match: /dev/input/event0
[INFO   ] MTD: Read event from </dev/input/event0>
[INFO   ] Base: Start application main loop
[INFO   ] MTD: </dev/input/event0> range position X is 0 - 800
[INFO   ] MTD: </dev/input/event0> range position Y is 0 - 480
[INFO   ] MTD: </dev/input/event0> range touch major is 0 - 0
[INFO   ] MTD: </dev/input/event0> range touch minor is 0 - 0
[INFO   ] MTD: </dev/input/event0> range pressure is 0 - 255
[INFO   ] MTD: </dev/input/event0> axes invertion: X is 0, Y is 0
[INFO   ] MTD: </dev/input/event0> rotation set to 0
[DEBUG  ] ImageSDL2: Load </photos/01a649559fae77beb14380c489820326ea205ca647.JPG>
[INFO   ] GL: NPOT texture support is available
[INFO   ] GL: Unpack subimage support is available
root@6fa947ee803c:/usr/src/app# cat /root/.kivy/logs/kivy_19-12-23_0.txt
[INFO   ] Logger: Record log in /root/.kivy/logs/kivy_19-12-23_0.txt
[WARNING] [Config      ] Upgrading configuration in progress.
[WARNING] [Config      ] Older configuration version detected (0 instead of 21)
[INFO   ] Kivy: v1.11.1
[INFO   ] Kivy: Installed at "/usr/local/lib/python3.7/dist-packages/kivy/__init__.py"
[INFO   ] Python: v3.7.3 (default, Apr  3 2019, 05:39:12) 
[GCC 8.3.0]
[INFO   ] Python: Interpreter at "/usr/bin/python3"
[INFO   ] Factory: 184 symbols loaded
[INFO   ] ImageLoaderFFPy: Using ffpyplayer 4.3.0
[INFO   ] Image: Providers: img_tex, img_dds, img_sdl2, img_pil, img_ffpyplayer, img_gif 
[DEBUG  ] App: Loading kv <./carousel.kv>
[DEBUG  ] App: kv <./carousel.kv> not found
[DEBUG  ] Window: Ignored <egl_rpi> (import error)
[INFO   ] Window: Provider: sdl2(['window_egl_rpi'] ignored)
[INFO   ] GL: Using the "OpenGL" graphics system
[INFO   ] GL: Backend used <sdl2>
[INFO   ] GL: OpenGL version <b'OpenGL ES 2.0'>
[INFO   ] GL: OpenGL vendor <b'Broadcom'>
[INFO   ] GL: OpenGL renderer <b'VideoCore IV HW'>
[INFO   ] GL: OpenGL parsed version: 2, 0
[INFO   ] GL: Shading version <b'OpenGL ES GLSL ES 1.00'>
[INFO   ] GL: Texture max size <2048>
[INFO   ] GL: Texture max units <8>
[DEBUG  ] Shader: Fragment compiled successfully
[DEBUG  ] Shader: Vertex compiled successfully
[DEBUG  ] ImageSDL2: Load </usr/local/lib/python3.7/dist-packages/kivy/data/glsl/default.png>
[INFO   ] Window: auto add sdl2 input provider
[INFO   ] Window: virtual keyboard not allowed, single mode, not docked
[DEBUG  ] Cache: register <kv.loader> with limit=500, timeout=60
[INFO   ] Loader: using a thread pool of 2 workers
[DEBUG  ] ImagePIL: Load </usr/local/lib/python3.7/dist-packages/kivy/data/images/image-loading.gif>
[DEBUG  ] Base: Create provider from mouse
[DEBUG  ] Base: Create provider from probesysfs
[DEBUG  ] ProbeSysfs: using probesysfs!
[DEBUG  ] ProbeSysfs: found device: FT5406 memory based driver at /dev/input/event0
[INFO   ] ProbeSysfs: device match: /dev/input/event0
[INFO   ] MTD: Read event from </dev/input/event0>
[INFO   ] Base: Start application main loop
[INFO   ] MTD: </dev/input/event0> range position X is 0 - 800
[INFO   ] MTD: </dev/input/event0> range position Y is 0 - 480
[INFO   ] MTD: </dev/input/event0> range touch major is 0 - 0
[INFO   ] MTD: </dev/input/event0> range touch minor is 0 - 0
[INFO   ] MTD: </dev/input/event0> range pressure is 0 - 255
[INFO   ] MTD: </dev/input/event0> axes invertion: X is 0, Y is 0
[INFO   ] MTD: </dev/input/event0> rotation set to 0
[DEBUG  ] ImageSDL2: Load </photos/01a649559fae77beb14380c489820326ea205ca647.JPG>
[INFO   ] GL: NPOT texture support is available
[INFO   ] GL: Unpack subimage support is available

我不确定是什么原因导致某些图像无法加载,我们将不胜感激任何有关下一步尝试的建议。

【问题讨论】:

  • 我能够通过 PIL 将图像全部缩小来加载图像。我仍然不知道为什么这会修复它,因为即使图像大小相似,图像也会显示或无法显示。

标签: python kivy raspberry-pi3


【解决方案1】:

我不知道这会是你的问题,但是当我遇到一些幻灯片图像无法在 Raspberry Pi 上使用 Kivy 显示(但在 Windows 上使用 Kivy 工作正常)的问题时,解决的方法是设置 nocache = 在 Image 实例上为 True。

【讨论】:

  • 我会试一试,看看我的原始代码会发生什么。