Nie*_*ved 8 c++ video opencv stream rtsp
例如,我们有工作rtsp流测试像:"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"
我尝试过几种不同的方式:
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");
}
Run Code Online (Sandbox Code Playgroud)
要么:
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;
}
Run Code Online (Sandbox Code Playgroud)
任何的想法 ?
-
Niedved
以下代码对我没有任何问题.如果您有流的用户名和密码,请不要忘记将其包含在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);
}
Run Code Online (Sandbox Code Playgroud)