Can't connect to cammera
I'am trying to connect to my hikvision DS-2CD2032-I camera, with no success.
Code:
import numpy as np
import cv2 as cv
cap = cv.VideoCapture('rtsp://username:password@IP:554/1')
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
# Display the resulting frame
cv.imshow('frame', gray)
if cv.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv.destroyAllWindows()
Error:
gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY) error: OpenCV(3.4.2) c:\build\3_4_winpack-bindings-win32-vc14-static\opencv\modules\imgproc\src\color.hpp:253: error: (-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'cv::CvtHelper<struct cv::set<3,4,-1="">,struct cv::Set<1,-1,-1>,struct cv::Set<0,2,5>,2>::CvtHelper'
With the same urls (["rtsp://user:password@IP:554/1", "rtsp://user:password@IP:554/h264_stream"]) I have managed to connect with VLC player, but not with this script.., also if I define cv.VideoCapture(0), my laptop camera capturing works with no problem.
Your help is greatly appreciated.
Comments
- cross-checking with vlc is a good idea already.
- make extra sure, you have the opencv_ffmpeg_64.dll on the PATH, since all video file / stream functionality is handled from there.