首页 > 代码库 > cvCreateTrackbar 用进度条做按钮

cvCreateTrackbar 用进度条做按钮

核心函数:

cvCreateTrackbar

程序:

wKioL1PsYIuRNcwhAAFaxDp4B_M745.jpg

代码:

#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <iostream>
int ButtonValue=http://www.mamicode.com/-1;"e:\\picture\\11.jpg");
void ButtonCallback(int position)  //回调函数
{
if(position==0)
{
cvShowImage("src",src);
std::cout<<"off"<<std::endl;
}
else
{
IplImage* gray=cvCreateImage(cvGetSize(src),8,1);
cvCvtColor(src,gray,CV_BGR2GRAY);
cvShowImage("src",gray);
std::cout<<"on"<<std::endl;
}
}
int button(int argc,char** argv)
{
cvNamedWindow("src",0);
cvCreateTrackbar("button","src",&ButtonValue,1,ButtonCallback); //创建按钮,并且注册回调函数
cvShowImage("src",src);
cvWaitKey(0);
cvDestroyWindow("src");
cvReleaseImage(&src);
return 0;
}


本文出自 “flyclc” 博客,请务必保留此出处http://flyclc.blog.51cto.com/1385758/1539944