Python - AndroidViewClient take snapshots in high FPS

这一生的挚爱 提交于 2019-12-25 04:11:51

问题


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?


回答1:


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)

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.

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.



来源:https://stackoverflow.com/questions/53143331/python-androidviewclient-take-snapshots-in-high-fps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!