简体   繁体   English

在Linux Angstrom上使用Python显示图像

[英]Display an image with Python on Linux Angstrom

I have a Python script that displays images fullscreen on a BeagleBoard with the GUI disabled. 我有一个Python脚本,在禁用了GUI的BeagleBoard上全屏显示图像。 The script is started when the board boots. 板启动时启动脚本。 For this I use PyGame which works perfectly fine. 为此,我使用了PyGame,它工作得很好。 Except for some reason the image qwality is scaled down. 除非出于某些原因,图像质量会按比例缩小。 Because the images are stored in HQ I assume that PyGame resamples the image. 因为图像存储在总部,所以我假设P​​yGame对图像进行重新采样。 I was unable to find out where this can be changed so I decided to replace PyGame, it also seems a bit much to "just" display an image. 我无法找到可以更改的地方,因此我决定替换PyGame,“仅”显示图像似乎也有些不足。

I have the code below to display the image. 我有下面的代码来显示图像。 According to documentation the default image viewer will show the image. 根据文档,默认的图像查看器将显示图像。 (Which is supposed to be XV). (应该是XV)。 But as soon as I run the code below where image is a filepath I get "sh: xv: not found". 但是,只要我在图像是文件路径的以下代码中运行,就会得到“ sh:xv:not found”。

from PIL import Image
im = Image.open(image)
im.show()

So I tried to install the XV package but can't find how to install it for Angstrom. 因此,我尝试安装XV软件包,但找不到如何为Angstrom安装它。

My question could either be "How to display images fullscreen with Python?" 我的问题可能是“如何使用Python全屏显示图像?” (To which the answer was supposed to be the code above). (答案应该是上面的代码)。 Or the question is "How can I get XV installed on Angstrom?" 或问题是“如何在Angstrom上安装XV?” (What is the package name for opkg install) (opkg install的软件包名称是什么)

I did search, but haven't found something that works... 我确实进行了搜索,但没有找到有效的方法...

Image.show() in PIL is more intended for debugging than actual, production use. PIL中的Image.show()比实际的生产用途更多地用于调试。 It is hardcoded to call xv <temp-image-file-pil-creates> . 调用xv <temp-image-file-pil-creates>是硬编码的。 You can hack around this (make a symbolic link called xv that will call some other image viewer), but it's still a rather bad way to go about it. 您可以解决这个问题(创建一个名为xv的符号链接,该链接将调用其他图像查看器),但是这样做仍然是一种相当糟糕的方法。

I don't know enough about the BeagleBoard to tell you the best/canonical way to display an image fullscreen, but if you got halfway there with PyGame, perhaps you can post your code and the community can help you fix the quality problem. 我对BeagleBoard的了解还不够,无法告诉您全屏显示图像的最佳/规范方法,但是如果您在PyGame方面尚不成熟,也许您可​​以发布代码,社区可以帮助您解决质量问题。

If the image is getting downscaled to fit the screen, you might look into using transform.smoothscale to scale the image manually (to avoid losing quality). 如果图像正缩小以适合屏幕大小,则可以考虑使用transform.smoothscale手动缩放图像(以避免质量下降)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM