Peter  Lunk
Published © GPL3+

How to Use the Android 'IP Webcam' App with Python / OpenCV

Using OpenCV open source library with a IP camera using RasPi3b

IntermediateProtip6 minutes25,542
How to Use the Android 'IP Webcam' App with Python / OpenCV

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1

Software apps and online services

OpenCV
OpenCV
Py2CV3
IP Webcam (Android IP cam App)

Story

Read more

Code

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

Python
# Using Android IP Webcam video .jpg stream (tested) in Python2 OpenCV3

import urllib
import cv2
import numpy as np
import time

# Replace the URL with your own IPwebcam shot.jpg IP:port
url='http://192.168.2.35:8080/shot.jpg'


while True:
    # Use urllib to get the image from the IP camera
    imgResp = urllib.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

Credits

Peter  Lunk

Peter Lunk

5 projects • 31 followers

Comments