python链接海康摄像头,并以弹出框的方式播放实时视频流,
@shared_task def parse_video(rtsp_address=None): winname = ‘Video‘ if not rtsp_address: raise exceptions.ParseError(‘摄像头rstp地址错误!‘) cap = cv2.VideoCapture(rtsp_address) if not cap.isOpened(): raise exceptions.ParseError(‘视频播放失败!‘) while cap.isOpened(): ret, frame = cap.read() if not ret: break cv2.putText(frame, ‘Please press "ESC" to close the window‘, (900, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (55, 255, 155), 1) cv2.imshow(winname, frame) k = cv2.waitKey(1) if cv2.getWindowProperty(winname, cv2.WND_PROP_AUTOSIZE) < 1: break if k == 27: break cap.release() cv2.destroyAllWindows()
原文:https://www.cnblogs.com/52-qq/p/11803463.html