Python + opencv 操作远程IP摄像头
#!/usr/bin/env python'''Usage:------ipcam.pyKeys:-----ESC - exit'''# Python 2/3 compatibilityfrom __future__ import print_functionimport sysPY3 = sys.version_info
#!/usr/bin/env python
'''
Usage:
------
ipcam.py
Keys:
-----
ESC - exit
'''
# Python 2/3 compatibility
from __future__ import print_function
import sys
PY3 = sys.version_info[0] == 3
if PY3:
xrange = range
import cv2
import urllib
import numpy as np
print(__doc__)
stream=urllib.urlopen('http://admin:admin@192.168.3.66:8081/video')
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.IMREAD_COLOR)
cv2.imshow('i',i)
if cv2.waitKey(1) ==27:
exit(0)
更多推荐
所有评论(0)