#include "cv.h"
#include "highgui.h"
#include "stdio.h"
void main()
{
CvCapture* capture = 0;
CvVideoWriter* wrt = 0;
IplImage* frame = 0;
double fps, width, height, count;
capture = cvCaptureFromFile("F:\\运动目标检测与跟踪\\视频\\Laboratory_raw.AVI");
//capture = cvCaptureFromCAM( -1 );
if( !capture )
{
fprintf(stderr,"Could not initialize capturing...\n");
return;
}
cvNamedWindow( "frame", 0 );
while(1)
{
frame = cvQueryFrame( capture );
wrt = cvCreateVideoWriter("D:\\Vc++\\视频\\1.avi", CV_FOURCC('P','I','M','1'), 10.0 , cvGetSize(frame), 0);
if( !frame )
{
fprintf(stderr,"Could not initialize frame...\n");
return;
}
fps=cvGetCaptureProperty(capture,CV_CAP_PROP_FPS);
width = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH );
height = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT );
count = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_COUNT );
printf("fps = %f, width * height = %f * %f, count = %f\n",fps, width, height, count);
cvShowImage("frame", frame);
if( cvWaitKey(100) >= 0 )
break;
}
cvReleaseCapture(&capture );
cvReleaseVideoWriter(&wrt);
cvDestroyWindow("frame");
}
/*
//自已算FPS
DWORD sTimeShapeVector = 0;
DWORD cTimeShapeVector = 0;
long fps_SV_frame_count =0 ;
sTimeShapeVector = timeGetTime();
cTimeShapeVector = 0;
fps_SV_frame_count =0 ;
for(;;)
{
if(fps_SV_frame_count%15==0)
{
cTimeShapeVector = timeGetTime();
float fps = (float) 15 * 1000 / (cTimeShapeVector - sTimeShapeVector);
cout<<"fps="<<fps<<endl;
opencv_fps = fps;
sTimeShapeVector = timeGetTime();
}
fps_SV_frame_count++;
}
*/