[英]How to capture android screen using python
我想使用python(使用opencv或其他庫)對我的android屏幕進行一些圖像處理。
我是一個python程序員,因此不想使用android工作室或學習其他工具進行圖像處理只是為了這個特殊的小任務。
如何通過usb / ip /其他任何方式使用python將手機連接到屏幕流到我的電腦?
我也不介意在python中編寫代碼並在可能的情況下在android上運行它。
嘗試這個但你需要使用這個基本上是IP攝像頭的應用程序https://play.google.com/store/apps/details?id=com.pas.webcam
# Stream Video with OpenCV from an Android running IP Webcam (https://play.google.com/store/apps/details?id=com.pas.webcam)
# Code Adopted from http://stackoverflow.com/questions/21702477/how-to-parse-mjpeg-http-stream-from-ip-camera
import cv2
import urllib2
import numpy as np
import sys
host = "192.168.0.220:8080"
if len(sys.argv)>1:
host = sys.argv[1]
hoststr = 'http://' + host + '/video'
print 'Streaming ' + hoststr
stream=urllib2.urlopen(hoststr)
bytes=''
while True:
bytes+=stream.read(1024)
a = bytes.find('\xff\xd8')
b = bytes.find('\xff\xd9')
if a!=-1 and b!=-1:
jpg = bytes[a:b+2]
bytes= bytes[b+2:]
i = cv2.imdecode(np.fromstring(jpg, dtype=np.uint8),cv2.CV_LOAD_IMAGE_COLOR)
cv2.imshow(hoststr,i)
if cv2.waitKey(1) ==27:
exit(0)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.