第一种办法 单张图获取
网页打开
#//http://192.168.1.82/webcapture.jpg?command=snap&channel= 1 网页打开直接抓一张图
python
#//http://192.168.1.83/webcapture.jpg?command=snap&channel= 1 import cv2 url = 'http://192.168.1.83/webcapture.jpg?command=snap&channel=1' savepath="./1.jpg" cap = cv2.VideoCapture(url) while(cap.isOpened()): ret, frame = cap.read() cv2.imshow('frame',frame) cap = cv2.VideoCapture(url) #if cv2.waitKey(1) & 0xFF == ord('q'): # break if cv2.waitKey(1) & 0xFF == ord('s'): cv2.imwrite(savepath, frame,[int(cv2.IMWRITE_JPEG_QUALITY), 100]) #cv2.imwrite("D:/test.png", frame) break cap.release() cv2.destroyAllWindows()
第二种办法
rtsp连续流
import cv2 cap = cv2.VideoCapture("rtsp://192.168.1.151:554/useradmin&password=&channel=1&stream=0.sdp?") #0.sdp主码流 1次码流 ret,frame = cap.read() while ret: ret,frame = cap.read() cv2.imshow("frame",frame) if cv2.waitKey(1) & 0xFF == ord('q'): break cv2.destroyAllWindows() cap.release()
最新评论