⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 capture-frame.cpp

📁 opencv codes in C++ (linux and eclipse)
💻 CPP
字号:
/* program to capture 100th frame from video and display the 100th frame in the image.   When the frame reaches the 100th frame, its is saved in another image */#include "cv.h"#include "cvaux.h"#include "highgui.h"#include <stdio.h>int main( int argc, char** argv ){			/* capture video from file*/	CvCapture* capture = cvCaptureFromFile("out.avi"); 	IplImage* img = 0; 		cvNamedWindow("Original Image",1);	cvNamedWindow("100th Frame",1);			if(!cvGrabFrame(capture))	{              // capture a frame   		printf("Could not grab a frame !!! \n");  		exit(0);	}		int key;	int numFrames; 		for (;;) 		{			img=cvRetrieveFrame(capture); 			if (!img) 				{					break;				}			if(cvGrabFrame(capture))				{ 										numFrames = (int)(cvGetCaptureProperty(capture, CV_CAP_PROP_POS_FRAMES));					printf("Frame: %d\n",numFrames);					//img=cvRetrieveFrame(capture);  					cvShowImage("Original Image", img); 					cvMoveWindow("100th Frame",500,0);							if ( numFrames == 100 )					{ 			  			cvSaveImage("resultant image of 100th frame.jpg",img);  						cvShowImage("100th Frame",img);  			  	    }	  				else   					key = cvWaitKey(400);			   }		  else			  {				printf("reached at the end of the frame!!!!\n");				exit(0);			  }  	}	cvWaitKey(0);	cvReleaseCapture(&capture);	return 0;  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -