zoukankan      html  css  js  c++  java
  • OpenCV学习笔记——滑动条开关

    由于opencv库中并没有专门为开关而设的函数,可以用滑动条做开关

    代码:

    #include<highgui.h>
    #include<cv.h>
    int g_switch_value = 0;
    IplImage *img;
    void switch_off_fcuntion();
    void switch_on_function();
    void switch_callback(int position)
    {
    	if (!position)
    	{	
    		switch_off_fcuntion();
    	}
    	else
    	{		
    		switch_on_function();		
    	}
    }
    int main(void)
    {
    	cvNamedWindow("sample",1);
    	cvCreateTrackbar("Switch", "sample", &g_switch_value, 1, switch_callback);//中间的数值用来自定义可变换区间长度
    	while (1)
    	{
    		if (cvWaitKey(15) == 27)
    		{
    			cvReleaseImage(&img);
    			cvDestroyAllWindows();
    			break;
    		}
    	}
    	return 0;
    }
    void switch_off_fcuntion()
    {
    	puts("This is q1");
    	img = cvLoadImage("q1.jpg", -1);
    	cvShowImage("sample", img);
    	puts("Q1");
    	return;
    }
    void switch_on_function()
    {
    	puts("This is q1");
    	img = cvLoadImage("q2.jpg", -1);
    	cvShowImage("sample", img);
    	puts("Q2");
    	return;
    }
  • 相关阅读:
    SPOJ
    基础计算几何
    数颜色
    Codeforces 986B
    一些有趣的题
    jQuery
    linux命令学习
    javaScript
    css
    html
  • 原文地址:https://www.cnblogs.com/Blackops/p/5766280.html
Copyright © 2011-2022 走看看