Created
February 6, 2020 02:27
-
-
Save ryanbekabe/5da516abc53f7d84bf031963f55ec736 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using Android IP Webcam video / mjpeg .jpg stream (tested) in Python37 OpenCV | |
# TheBekabe - HanyaJasa.Com - [email protected] | |
import urllib | |
import urllib.request | |
import cv2 | |
import numpy as np | |
import time | |
# Replace the URL with your own IPwebcam shot.jpg IP:port | |
url='http://192.168.43.1:8080/shot.jpg' | |
while True: | |
# Use urllib to get the image from the IP camera | |
imgResp = urllib.request.urlopen(url) | |
# Numpy to convert into a array | |
imgNp = np.array(bytearray(imgResp.read()),dtype=np.uint8) | |
# Finally decode the array to OpenCV usable format ;) | |
img = cv2.imdecode(imgNp,-1) | |
# put the image on screen | |
cv2.imshow('IPWebcam',img) | |
#To give the processor some less stress | |
#time.sleep(0.1) | |
# Quit if q is pressed | |
if cv2.waitKey(1) & 0xFF == ord('q'): | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment