Python-AndroidViewClient以高FPS拍摄快照 [英] Python - AndroidViewClient take snapshots in high FPS

查看:138
本文介绍了Python-AndroidViewClient以高FPS拍摄快照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Python上使用AndroidViewClient以60 FPS拍摄设备的快照,因此我在循环中使用了功能 device.takeSnapshot(reconnect = True)所以。但是,此功能的时间消耗约为0.5秒,这使我获得2 FPS。我认为重新连接使它变得很长。那么,为什么拍摄一张快照后设备会自动断开连接?有没有办法保持连接?还有其他方法可以减少时间消耗并获得更高的FPS吗?

I wanted to take snapshots of my device in 60 FPS using AndroidViewClient on Python, so I used the function device.takeSnapshot(reconnect=True) in a loop to do so. However, it appeared that the time consumption of this function is around 0.5 seconds which gives me 2 FPS. I think the re-connection is what it makes it long. So why the device disconnects automatically after taking one snapshot? Is there a way to keep the connection on? Is there any other way to improve time consumption and get higher FPS?

推荐答案

虽然不是 AndroidViewClient / culebra 的目标是成为屏幕记录 er,我进行了这样的测试

Although it's not AndroidViewClient/culebra's objective to be a screenrecorder, I ran a test like this

device, serialno = ViewClient.connectToDeviceOrExit()
t = time.time()
for s in range(60):
    device.takeSnapshot(reconnect=True)
t1 = time.time()-t
print "t={} secs  r={} screenshots/sec".format(t1, 60/t1)

,并在快速手机上(像素3)可以在15秒内拍摄60张屏幕截图或 4 FPS
另外,还要考虑到屏幕尺寸为1080x2160,因此要传输很多字节。

and on a fast phone (Pixel 3) it can take 60 screenshots in 15 secs or 4 FPS. Also, take into account that the screen size is 1080x2160 so there's a lot of bytes to transfer.

您可以看看 takeSnapshot()源代码,并看到有一些可以删除或更改的部分,例如PIL Image 可以推迟的创建。

You can take a look at takeSnapshot() source code and see that there are some parts you can remove or change if you want to speed it up, like the PIL Image creation that could be deferred.

这篇关于Python-AndroidViewClient以高FPS拍摄快照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆