[英]OpenCV - how to capture rtsp video stream
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) 例如,我们有工作rtsp流测试像:“rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov”(它在发布这篇文章的时候工作)
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" 现在我想在openCV中捕获这个视频流(opencv 2.4.7 / 2.4.8)我的代码完全适用于本地电影文件,但当我尝试捕获rtsp时,我得到的信息如下:“无法读取电影文件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 Niedved
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. 如果您有流的用户名和密码,请不要忘记将其包含在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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.