标签:cvcreatetrackbar 用进度条做按钮 opencv
核心函数:
cvCreateTrackbar
程序:
代码:
#include "cv.h" #include "cxcore.h" #include "highgui.h" #include <iostream> int ButtonValue=-1; IplImage* src=cvLoadImage("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
cvCreateTrackbar 用进度条做按钮,布布扣,bubuko.com
标签:cvcreatetrackbar 用进度条做按钮 opencv
原文地址:http://flyclc.blog.51cto.com/1385758/1539944