开关openCV

 1 #include <cv.h>  
 2 #include <highgui.h>  
 3 #include <stdio.h>  
 4 //开关
 5 
 6 int g_switch_value = 0;
 7 
 8 void switch_callback(int position)
 9 {
10     if(position == 0)
11     {
12         printf("off
");
13     }
14     else
15     {
16         printf("on
");
17     }
18 }
19 
20 int main()
21 {
22     cvNamedWindow("Demo Window",1);
23     cvCreateTrackbar(
24         "Switch",
25         "Demo Window",
26         &g_switch_value,
27         1,
28         switch_callback
29         );
30     while (1)
31     {
32         if(cvWaitKey(15) == 27) break;
33 
34     }
35 }

 

原文地址:https://www.cnblogs.com/cjshuang/p/5690668.html