Trouble with openCV getting a stream using a Hikvision camera

What format is your source stream in? Is it MJPEG or RTSP?

I am pretty sure all hick cameras support RTSP so I would think it would be easier to just open the stream using the RTSP_URL as

VideoCapture cap(RTSP_URL);
Mat frame; cap.read(frame);

Note:

  1. The RTSP_URL url starts rtsp:// see the hickvision docs for info.
  2. Check that you can open the RTSP_URL in VLC media player without filling in the username and password pop up box before attempting to open it with VideoCapture.