IplImage* doPyrDown(IplImage* in, int filter = IPL_GAUSSIAN_5x5) {
//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);
return out;
}
//下面是从别人那里参考的
int g_scaling = 2;
void onTrackbarSlide2(int pos) {
g_scaling = pos + 2;
}
void fromCamera3() {
CvCapture* capture = cvCreateCameraCapture(0);
cvNamedWindow("camera", CV_WINDOW_AUTOSIZE);
if(capture != NULL) {
IplImage* in_frame = NULL;
IplImage* out_frame = NULL;
cvCreateTrackbar(
"Rate",
"camera",
&g_slider_position,
6,
onTrackbarSlide2
);
while(1) {
in_frame = cvQueryFrame(capture);
if(!in_frame) {
break;
}
out_frame = doPyrDown(in_frame);
//
for(int i=2; i<g_scaling; i++) {
out_frame = doPyrDown(out_frame);
}
cvShowImage("camera", out_frame);
char c = cvWaitKey(33);
if(c==27) break;
}
} else {
std::cout<<"NULL"<<std::endl;
}
cvReleaseCapture(&capture);
cvDestroyWindow("camera");
}