Python图像全屏显示
需要在嵌入式设备上全屏显示图像,使用pil显示图像时,只能通过系统的图像浏览器显示。所以使用Python自带的tkinter
import Tkinter as tk 这句在Python3中已经改成了 import tkinter as tk
top = Tk() #导入tk模块
from PIL import Image, ImageTk
image = Image.open("lenna.jpg")
photo = ImageTk.PhotoImage(image)
label = Label(top)
label.pack()
label.configure(image = photo )
top.mainloop()
在Ubuntu下需要安装:
sudo apt-get install python3-tk
sudo apt-get install python3-pil.imagetk
win下无需安装
使用PIL的原因是tkinter自己无法显示jpg图像
功能验证代码:
#!/usr/bin/python3
#!/usr/local/bin/python3 from tkinter import *
from PIL import Image, ImageTk top = Tk() #导入tk模块
top.attributes("-fullscreen", True)
width=top.winfo_screenwidth()
height=top.winfo_screenheight()
print(width,height)
image = Image.open('d:/cur/proj/j20/3.jpg')
photo = ImageTk.PhotoImage(image.resize((width,height)))
label = Label(top)
label.pack(expand=YES,fill=BOTH) #让图像在中央填充
label.configure(image = photo )
top.mainloop()
完成功能验证后,编写了刷图像的程序:
def display_thread():
global label,top
while True:
t1=time.time()
image = Image.open('d:/cur/proj/j20/3.jpg')
photo = ImageTk.PhotoImage(image.resize((width,height)))
#photo = ImageTk.PhotoImage(image)
label.configure(image = photo )
#top.update_idletasks()
time.sleep(0.03)
t2=time.time()
print(t2-t1)
发现图像显示出现了闪屏,而且帧率只有5~10帧,CPU占用率已达到单核90%
而实测image = Image.open('d:/cur/proj/j20/3.jpg')
仅需1ms,说明imagetk消耗时间长,无法满足30帧每秒的需求。
尚不知如何优化,换pyqt了
Python图像全屏显示的更多相关文章
- python Tkinter 全屏显示
#! /usr/bin/env python # -*- coding: utf-8 -*- import Tkinter as tk class FullScreenApp(object): def ...
- PyQt5图像全屏显示
Windows装这个:https://pypi.python.org/pypi/PyQt5Ubuntu输入这个:sudo apt-get install python3-pyqt5 或者直接输入:pi ...
- JavaScript:让浏览器全屏显示
并不是所有人都会按F11让浏览器全屏显示~~~ 一.直接上代码 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xh ...
- 在VC++6.0开发中实现全屏显示
全屏显示是一些应用软件程序必不可少的功能.比如在用VC++编辑工程源文件或编辑对话框等资源时,选择菜单“View\Full Screen”,即可进入全屏显示状态,按“Esc”键后会退出全屏显示状态. ...
- Android 全屏显示的方法(不包含状态栏)
我们都知道在Android中某些功能的实现往往有两种方法:一种是在xml文件中设置相应属性,另一种是用代码实现.同样Android实现全屏显示也可以通过这两种方法实现: 1.在AndroidManif ...
- Android 全屏显示
Android全屏显示: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInst ...
- QT5中全屏显示子窗口和取消全屏的方法
问题描述:用QT5做了个MDI多窗体应用程序,想把子窗体全屏显示,用网上的方法,但总是遇到问题. 网上的解决方法原文在这:http://www.cnblogs.com/Rick-w/archive/2 ...
- 启动app时全屏显示Default.png
一直很喜欢MJ的讲课视频,今天看了他的博客学到了些东西顺便记录下来. 在默认情况下,app显示Default.png时并非真正的"全屏显示",因为顶部的状态栏并没有被隐藏,比如下面 ...
- 【温故而知新-Javascript】窗口效果 (全屏显示窗口、定时关闭窗口)
1.全屏显示窗口 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ww ...
随机推荐
- o'Reill的SVG精髓(第二版)学习笔记——第十二章
第十二章 SVG动画 12.1动画基础 SVG的动画特性基于万维网联盟的“同步多媒体集成语言”(SMIL)规范(http://www.w3.org/TR/SMIL3). 在这个动画系统中,我们可以指定 ...
- 用c#语言编写1000以内能整除3的数字
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cons ...
- golang-Tag
Tag 理解 Golang中可以对struct定义Tag 例如: type TestTag struct{ UserName string `json:"name"` Age In ...
- (mybatis)There is no getter for property named 'isEffective' in 'class java.lang.String
原来代码: <select id="findSpecialOffer" resultType="com.lizard.back.model.SpecialOffer ...
- 执行计划sql
我准备开始分析并优化我的查询.在分析之前,我想到了一些问题. MS-SQL Server什么时候使用"Table Scan"? MS-SQL Server什么时候使用"I ...
- vue项目中使用vuex
1.运行 cnpm i vuex -S 2.导入包 import Vuex from 'vuex' 3.注册vuex到vue中 Vue.use(vuex) 4. var store = new Vue ...
- C++ string和int相互转换
首先需要C++ 11的支持 打开devC++,点击tools,点击编译环境,然后出现的框第一个勾选,输入-std=c++11即可 然后使用 to_string() 和 atoi() 就可以轻松实现其相 ...
- [JSOI2010]Group 部落划分 Group
Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 3661 Solved: 1755[Submit][Status][Discuss] Descripti ...
- 【赛时总结】NOIP2018-三校联考1024
◇NOIP三校联考-1024◇ 发现以前的博客写得似乎都很水……基本上都没什么阅读量QwQ 决定改过自新╰( ̄ω ̄o) 就从这篇博客开始吧~ 现场考得无地自容,看到题解才发现一些东西……(我第三题还没 ...
- NC使用技巧
1. NC 1.1概述 1.1.1 优点: 1)网络工具中的瑞士军刀 2)侦听模式/传输模式. 3)可代替telnet获取banner信息. 4)传输文件/目录. 5)传输文本信息. 6)加密传输文件 ...