I would like to do some image processing of my android screen using python (with opencv or other library).
I am a python programmer, thus don't want to use android studio or learn other tools for image processing just for this particular small task.
How can I connect my phone to stream its screen to my computer using python over usb/ip/anything else?
I also wouldn't mind writing the code in python and running it on android if possible.
Try this But you need to use this app that is basically IP camera 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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.