Last active
January 31, 2018 01:31
-
-
Save youqingkui/b4f88e3b607ed5e3239e645ef0a4dfac to your computer and use it in GitHub Desktop.
Revisions
-
youqingkui renamed this gist
Jan 31, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
youqingkui created this gist
Jan 31, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ import cv2 import urllib import numpy as np stream=urllib.urlopen('http://192.168.31.249:8080/video') 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('i',i) if cv2.waitKey(1) ==27: exit(0) import cv2 import requests import numpy as np r = requests.get('http://192.168.31.249:8080/video', stream=True) if(r.status_code == 200): bytes = bytes() for chunk in r.iter_content(chunk_size=1024): bytes += chunk a = bytes.find(b'\xff\xd8') b = bytes.find(b'\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.IMREAD_COLOR) cv2.imshow('i', i) if cv2.waitKey(1) == 27: exit(0) else: print("Received unexpected status code {}".format(r.status_code))