How To Open Ip Camera Url By Opencv And Python?
I have install opencv on MacX(Lion) with ffmpeg support import cv2 import cv import base64 import time import urllib2 import numpy as np from cv2 import __version__ print(__versi
Solution 1:
import cv2
import urllib
import numpy as np
stream=urllib.urlopen('http://localhost:8080/frame.mjpg')
bytes=''
while True:
bytes+=stream.read(16384)
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)
Post a Comment for "How To Open Ip Camera Url By Opencv And Python?"