//#include "stdafx.h"
#include "stdio.h"
#include "cv.h"
#include "highgui.h"
#include "cxcore.h"
int g_slide_position = 0;
IplImage * bgr_frame = 0;
IplImage * out1 = 0;
int width = 0;
int height = 0;
IplImage * doPyrDown(IplImage * in)
{
assert(in->width%2 == 0 && in->height%2 == 0);
IplImage * out = cvCreateImage(cvSize( in->width/2, in->height/2 ),in->depth,in->nChannels);cvPyrDown( in, out,CV_GAUSSIAN_5x5);
return( out );
}
void onTrackbarSlide (int pos)
{
out1 = bgr_frame;
while( pos != 0)
{
out1 = doPyrDown( out1);
pos--;
}
}
int main(int argc, char* argv[])
{
CvCapture* capture = cvCaptureFromCAM(0);
assert( capture != NULL );
width = cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH);
height = cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT);
cvNamedWindow("bianma",1);
cvNamedWindow("bianma2",1);
cvCreateTrackbar("position","bianma",&g_slide_position,3,onTrackbarSlide);
/*CvVideoWriter* writer = cvCreateVideoWriter("hahaB.avi",CV_FOURCC('X','V','I','D'),30,cvSize( width/2, height/2));*/
while(1)
{
bgr_frame = cvQueryFrame(capture);
if(! bgr_frame)
break;
//out = doPyrDown(bgr_frame);
char c = cvWaitKey(33);
if(c == 27)
{
// cvReleaseImage( &bgr_frame);
break;
}
cvShowImage("bianma",bgr_frame);
cvShowImage("bianma2",out1);
//cvWriteFrame( writer, out );
}
//cvReleaseVideoWriter( &writer );
cvReleaseCapture( &capture );
cvDestroyWindow("bianma");
return(0);
}