cvCreatetrackbar()中的回调函数问题

cvCreatetrackbar()中的回调函数问题_第1张图片cvCreatetrackbar()中的回调函数问题_第2张图片

cvCreatetrackbar()中的回调函数问题

#include <cv.h>
#include <highgui.h>
int g_threshold=102;
IplImage* src=cvLoadImage("lenaGRAY.jpg",0);
void on_trackbar(int pos)
{
IplImage *dst=cvCreateImage(cvGetSize(src),src->depth,src->nChannels);
CvMemStorage* storage=cvCreateMemStorage(0);
CvSeq *seq=NULL;
cvThreshold(src,dst,pos,255,CV_THRESH_BINARY);
cvFindContours(dst,storage,&seq);
cvDrawContours(dst,seq,cvScalarAll(255),cvScalarAll(255),100);
cvShowImage("binary image",dst);
cvReleaseImage(&dst);
cvClearMemStorage(storage);
}
int main()
{
cvNamedWindow("source image",1);
cvShowImage("source image",src);
cvNamedWindow("binary image",1);
cvCreateTrackbar("slider","binary image",&g_threshold,255,on_trackbar);
on_trackbar(g_threshold);
cvWaitKey(0);
cvReleaseImage(&src);
cvDestroyAllWindows();
return 0;
}

你可能感兴趣的:(image,DST)