pyramid.cpp

来自「opencv codes in C++ (linux and eclipse)」· C++ 代码 · 共 59 行

CPP
59
字号
#include "cv.h"#include "cvaux.h"#include "highgui.h"#include <stdio.h>int main(int argc, char** argv){	     IplImage* tmp_frame = NULL;     CvCapture* cap = NULL;     //capture frame from video file     cap =   cvCaptureFromFile("out.avi");      //query the frame     tmp_frame = cvQueryFrame(cap);     // create an image     IplImage* output = cvCreateImage( cvSize(tmp_frame->width/2,tmp_frame->height/2),tmp_frame->depth,tmp_frame->nChannels );          if(!tmp_frame)     {         printf("bad video \n");         exit(0);     }     //windows to display images.     cvNamedWindow("BackGround", 1);     cvNamedWindow("ForeGround", 1);     cvNamedWindow( "pyramid",1 );             //create BG model     CvBGStatModel* bg_model = cvCreateGaussianBGModel( tmp_frame );     //CvBGStatModel* bg_model = cvCreateFGDStatModel( tmp_frame );//loop through each frame     for( int fr = 1;tmp_frame; tmp_frame = cvQueryFrame(cap), fr++ )      {      	//update the frame        cvUpdateBGStatModel( tmp_frame, bg_model );	//display background image        cvShowImage("BackGround", bg_model-> background);         //display foreground image        cvShowImage("ForeGround", bg_model-> foreground);        cvMoveWindow("ForeGround",500,0);        //pyramid image        cvPyrDown( tmp_frame, output,IPL_GAUSSIAN_5x5 );		//displaying image        cvShowImage("pyramid", output);        cvWaitKey(50);        	if(cvWaitKey(10) >= 0)                break;      }            cvReleaseBGStatModel( &bg_model );      cvReleaseCapture(&cap);            return 0;}

⌨️ 快捷键说明

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