OpenCV - how to capture rtsp video stream

For example, we have a working rtsp stream test, for example: "rtsp: //184.72.239.149/vod/mp4: BigBuckBunny_115k.mov" (it works at the time of publication of this message)

Now I want to catch this video stream in openCV (opencv 2.4.7 / 2.4.8) My code works fine in local movie files, but when I try to capture rtsp, I get messages like: "Could not read rtsp movie file: / /184.72.239.149/vod/mp4: BigBuckBunny_115k.mov "

I tried several different ways:

CvCapture *camera = cvCreateFileCapture("rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov"); if (camera == NULL) { printf("video is null, aborting..."); return -1; } else{ printf("video ok"); } 

or

 cv::VideoCapture vcap; //open the video stream and make sure it opened if(!vcap.open("rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov")) { std::cout << "Error opening video stream or file" << std::endl; return -1; } 

Any idea?

-

Niedved

+6
source share
1 answer

The following code works for me without any problems. If you have a username and password for the stream, be sure to include it in the URL.

 cv::VideoCapture capture(url); if (!capture->isOpened()) { //Error } cv::namedWindow("TEST", CV_WINDOW_AUTOSIZE); cv::Mat frame; while(m_enable) { if (!capture->read(frame)) { //Error } cv::imshow("TEST", frame); cv::waitKey(30); } 
+8
source

All Articles