在视频的左上角动态显示帧数、参看帧率

在视频的左上角动态显示帧数:

Mat current;
int frameCount = 0;
frameCount++;
stringstream buf;
buf << frameCount;
string num = buf.str();//帧数
//在图像左上角显示帧数
putText(current, num, Point(20, 30), FONT_HERSHEY_SIMPLEX, 1, Scalar(0, 0, 255), 3);


//用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;
}


你可能感兴趣的:(C++,OpenCV)