#include "cv.h"
#include "highgui.h"
#include <iostream>
using namespace cv;
int main(int, char**) {
cv::VideoCapture vcap;
cv::Mat image;
const std::string videoStreamAddress = "rtsp://192.168.1.100:554/onvif/live/1"; //rtsp://192.168.1.100:554/onvif/live/1
if(!vcap.open(videoStreamAddress)) {
std::cout << "Error opening video stream or file" << std::endl;
return -1;
}
int counter = 0;
for(;;)
{
counter++;
if(!vcap.read(image))
{
std::cout << "No frame" << std::endl;
cv::waitKey();
}
// if the picture is too large, imshow will display warped images, so show only every 2th frame
if (counter %2!= 0)
continue;
cv::imshow("Output Window", image);
double rate=vcap.get(CV_CAP_PROP_FPS);
std::cout<<"帧率为:"<<rate<<std::endl;
if(cv::waitKey(1) >= 0) break;
}
return 0;
}
该程序因接受速度和解码速度不匹配,会有些错误。