以下のようなコード ブロックがありますが、接続を確認できません。カメラが接続できない場合、接続エラーを出力したい。手伝って頂けますか。
import numpy as np
import cv2
cap = cv2.VideoCapture('rtsp://admin:12345678@192.168.102.114:554/ch01_sub.264')
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('ouput.avi', fourcc, 20.0, (640,480))
while(cap.isOpened()):
ret, frame = cap.read()
if ret == True:
frame = cv2.flip(frame,0)
out.write(frame)
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
break
cap.release()
out.release()
cv2.destroyAllWindows()