for example we have working rtsp stream test like: "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov" (it works in moment of publishing this post)
Now I want to catch this video stream in openCV (opencv 2.4.7 / 2.4.8) I've my code works perfectly on local movie files but when I try to capture rtsp I get msgs like: "Couldn't read movie file rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov"
I've tried few different ways like:
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's 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
Steps to capture a video:Use cv2. VideoCapture( ) to get a video capture object for the camera. Set up an infinite while loop and use the read() method to read the frames using the above created object. Use cv2.
OpenCV provides a very simple interface to do this. Let's capture a video from the camera (I am using the built-in webcam on my laptop), convert it into grayscale video and display it. Just a simple task to get started. To capture a video, you need to create a VideoCapture object.
The following code works for me without any problem. If you have a username and password for the stream, do not forget to include it in the url address.
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With