opencv rtsp 人脸识别
import cv2
import dlib
import json
face_detector = dlib.get_frontal_face_detector()
cap = cv2.VideoCapture("rtsp://admin:123@192.168.0.244:554/h264/ch6/main/av_stream")
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
ret,frame = cap.read()
while ret:
ret,frame = cap.read()
#frame = cv2.imread('r.jpg')
cv2.imshow("frame",frame)
gray = frame#cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces=face_detector(gray)
# print faces
for i in faces:
#print i.left(),i.right()
f=gray[i.top()-20: i.bottom()+20 , i.left()-20 : i.right()+20,:]
cv2.imshow('face',f)
#cv2.imwrite('2.jpg',f)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cv2.destroyAllWindows()
cap.release()
回放
rtsp://admin:123@192.168.0.244:554/Streaming/tracks/6?starttime=20181128t113812z&endtime=20181129t164816z