用OpenCV查看视频信息(视频的宽度、高度、帧率和总帧数)

用OpenCV查看视频信息,包括:视频的宽度、高度、帧率和总帧数。

详细代码如下:

//用OpenCV查看视频信息(视频的宽度、高度、帧率和总帧数)

#include "stdafx.h"
#include   
#include   


int main(int argc, char* argv[])
{
	IplImage *nFrames = NULL;
	CvCapture* pCapture = NULL;


	if( !(pCapture = cvCaptureFromAVI("C:\\zcd.avi")))
	{
		fprintf(stderr, "Can not open camera.\n");
		return -1;
	}


	int frameH    = (int) cvGetCaptureProperty(pCapture, CV_CAP_PROP_FRAME_HEIGHT);  
	int frameW    = (int) cvGetCaptureProperty(pCapture, CV_CAP_PROP_FRAME_WIDTH);  
	int fps       = (int) cvGetCaptureProperty(pCapture, CV_CAP_PROP_FPS);  
	int numFrames = (int) cvGetCaptureProperty(pCapture, CV_CAP_PROP_FRAME_COUNT);  
	printf("vedio's \nwidth = %d\t height = %d\n video's fps = %d\t nums = %d", frameW, frameH, fps, numFrames);


	getchar();
	return 0;
}
 
 

你可能感兴趣的:(OpenCV,查看视频信息,视频的宽度,高度,帧率,OpenCV)