Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Stream Video with OpenCV in Python from an Android running IP Webcam
# Stream Video with OpenCV from an Android running IP Webcam (
# Code Adopted from
import cv2
import urllib2
import numpy as np
import sys
host = ""
if len(sys.argv)>1:
host = sys.argv[1]
hoststr = 'http://' + host + '/video'
print 'Streaming ' + hoststr
while True:
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)
if cv2.waitKey(1) ==27:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment