是否有一种使用Python镜像Android设备的方法



我正在设计一个应用程序,该应用程序使用ADB将我的Android设备镜像到桌面。但是显然,此方法每2秒仅采用1个屏幕截图。

import subprocess
import cv2, os
while True:
    subprocess.run(["adb", "shell", "screencap ","/sdcard/screen.png"], shell=True)
    subprocess.run(["adb", "pull", "/sdcard/screen.png"], shell=True)
    print("Capped")
    image = cv2.imread("screen.png")
    os.remove("screen.png") #in order to make sure that the image isnt overwrited the next iteration
    cv2.imshow("image", image)
    if cv2.waitKey(1) & 0xFF == ord('q'):
       cv2.destroyAllWindows()
       sys.exit() 

还有其他方法可以更快地镜像我的屏幕吗?

您可以使用屏幕拷贝(scrcpy工具(,它镜像机器上的Android手机。

最新更新