MrLunk

Android 'IP Webcam' App video stream import to Python OpenCV

May 25th, 2017
3,818
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. # Using Android IP Webcam video .jpg stream in Python2 OpenCV3
  2. # IP Webcam App -> https://play.google.com/store/apps/details?id=com.pas.webcam
  3.  
  4. import urllib
  5. import cv2
  6. import numpy as np
  7. import time
  8.  
  9. url='http://192.168.2.35:8080/shot.jpg'
  10.  
  11. while True:
  12.  
  13.     # Use urllib to get the image and convert into a cv2 usable format
  14.     imgResp=urllib.urlopen(url)
  15.     imgNp=np.array(bytearray(imgResp.read()),dtype=np.uint8)
  16.     img=cv2.imdecode(imgNp,-1)
  17.    
  18.     # put the image on screen
  19.     cv2.imshow('IPWebcam',img)
  20.  
  21.     #To give the processor some less stress
  22.     #time.sleep(0.1)
  23.  
  24.     if cv2.waitKey(1) & 0xFF == ord('q'):
  25.         break
  26.  
  27. #https://www.facebook.com/mrlunk
Add Comment
Please, Sign In to add comment