Ask Your Question

Can't connect to cammera

asked 2018-08-10 15:12:26 -0500

Justas gravatar image

I'am trying to connect to my hikvision DS-2CD2032-I camera, with no success.


import numpy as np
import cv2 as cv

cap = cv.VideoCapture('rtsp://username:password@IP:554/1')

    # Capture frame-by-frame
    ret, frame =

    gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)

    # Display the resulting frame
    cv.imshow('frame', gray)

    if cv.waitKey(1) & 0xFF == ord('q'):

# When everything done, release the capture


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&lt;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.

edit retag flag offensive close merge delete


  • 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.
berak gravatar imageberak ( 2018-08-11 00:53:34 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-08-11 05:58:05 -0500

Justas gravatar image

Thank you, the problem was with the dill as you have mentioned, now everything works like a charm!

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-08-10 15:12:26 -0500

Seen: 52 times

Last updated: Aug 10