现在的位置: 首页 > 综合 > 正文

VideoCapture

2014年09月20日 ⁄ 综合 ⁄ 共 678字 ⁄ 字号 评论关闭
#include<opencv2/opencv.hpp>
#include<iostream>
using namespace std;
using namespace cv;
int main()
{
    VideoCapture capture;
	capture.open("C:/Users/Administrator/Desktop/OpenTLD-master/datasets/06_car/car.mpg");
	if(!capture.isOpened())
	{
		cout<<"fail to open!"<<endl;
		return 0;
	}
	long totolFrameNumber = (long)capture.get(CV_CAP_PROP_FRAME_COUNT);
	int  height = (int)capture.get(CV_CAP_PROP_FRAME_HEIGHT);
	int  width  = (int)capture.get(CV_CAP_PROP_FRAME_WIDTH);
	cout<<"视频总帧数:"<<totolFrameNumber<<endl<<"一帧的像素高:"<<height<<" 像素宽:"<<width<<endl;
	double rate = capture.get(CV_CAP_PROP_FPS);
	cout<<"频率:"<<rate<<endl;
	Mat frame;
	namedWindow("car");
	while(capture.read(frame))
	{
	   imshow("car",frame); 
	}
	capture.release();
	system("pause");
}

抱歉!评论已关闭.