#include <iostream>
#include <cv.h>
#include <highgui.h>
void TrackBarFunc(int val);
struct _TrackBarData
{
char *Name; //trackbar的名字
int Pos; //trackbar的初始位置
int MaxValue; //上限値
};
_TrackBarData TBData={"TrackBar",127,255};
IplImage *imgA = cvCreateImage(cvSize(300,300),IPL_DEPTH_8U,3);
int main( int argc, char **argv)
{
cvSet (imgA, CV_RGB(0,255,0) );
cvNamedWindow("OpenCV",CV_WINDOW_AUTOSIZE);
cvCreateTrackbar( TBData.Name, "OpenCV", &TBData.Pos, TBData.MaxValue , TrackBarFunc);
cvWaitKey(0);
cvReleaseImage(&imgA);
cvDestroyAllWindows();
return 0;
}
void TrackBarFunc(int val)
{
std::cout << "now : " << val << "/n";
cvSet (imgA, CV_RGB(0,val,0) );
cvShowImage("OpenCV",imgA);
}
本文转自gnuhpc博客园博客,原文链接:http://www.cnblogs.com/gnuhpc/archive/2012/11/25/2787626.html,如需转载请自行联系原作者