在ubuntu 11.10中,用python截屏并将截屏转换为与图像模板匹配的this question兼容的格式的最快方法是什么?解决方法:xpresser是在ubuntu中工作的项目,该项目也使用opencv.在xutils module中,有一个用于截取屏幕截图的...

在ubuntu 11.10中,用python截屏并将截屏转换为与图像模板匹配的this question兼容的格式的最快方法是什么?
解决方法:
xpresser是在ubuntu中工作的项目,该项目也使用opencv.在xutils module中,有一个用于截取屏幕截图的功能,如下所示:
def take_screenshot(x=0, y=0, width=None, height=None):
window = gtk.gdk.get_default_root_window()
if not (width and height):
size = window.get_size()
if not width:
width = size[0]
if not height:
height = size[1]
pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height)
pixbuf = pixbuf.get_from_drawable(window, window.get_colormap(),
x, y, 0, 0, width, height)
array = pixbuf.get_pixels_array()
return Image("screenshot", array=array,
width=array.shape[1], height=array.shape[0])
我希望这有帮助.
沃梦达教程
本文标题为:python-将屏幕快照加载到内存中以进行简历模板匹配的最快方法


基础教程推荐
猜你喜欢
- [Python] Unofficial Windows Binaries for Python Extension Packages 2023-11-12
- 在windows上解决Command "python setup.py egg_info" fail 2023-09-03
- python-比较ctypes数组而无需额外的内存 2023-11-12
- linux中使用Python对图片进行批量命名 2023-08-11
- 如何将带有空格的字符串从Python发送到Bash子进程作为单个值? 2023-11-13
- Python中的getattr,__getattr__,__getattribute__和__get__详解 2023-08-09
- Python新年炫酷烟花秀代码 2023-08-11
- 安装Python3后,centos使用yum报错 2023-09-04
- Windows下用python来获取微信撤回消息 2023-09-04
- 交互式 shell 玩转 Python 2023-09-04