OpenCV学习——用Trackbar模仿一个按钮
来源:互联网 发布:淘宝买高仿包 编辑:程序博客网 时间:2024/06/05 20:08
// An example program in which the
// user can draw boxes on the screen.
//
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
/* License:
Oct. 3, 2008
Right to use this code in any way you want without warrenty, support or any guarentee of it working.
BOOK: It would be nice if you cited it:
Learning OpenCV: Computer Vision with the OpenCV Library
by Gary Bradski and Adrian Kaehler
Published by O'Reilly Media, October 3, 2008
AVAILABLE AT:
http://www.amazon.com/Learning-OpenCV-Computer-Vision-Library/dp/0596516134
Or: http://oreilly.com/catalog/9780596516130/
ISBN-10: 0596516134 or: ISBN-13: 978-0596516130
OTHER OPENCV SITES:
* The source code is on sourceforge at:
http://sourceforge.net/projects/opencvlibrary/
* The OpenCV wiki page (As of Oct 1, 2008 this is down for changing over servers, but should come back):
http://opencvlibrary.sourceforge.net/
* An active user group is at:
http://tech.groups.yahoo.com/group/OpenCV/
* The minutes of weekly OpenCV development meetings are at:
http://pr.willowgarage.com/wiki/OpenCV
*/
//
// Using a trackbar to create a "switch" that the user can turn on and off.
// We make this value global so everyone can see it.
//
int g_switch_value = 1;
void switch_off_function() {printf("Pause/n");}; //YOU COULD DO SOMETHING WITH THESE FUNCTIONS TOO
void switch_on_function() {printf("Run/n");};
//
// This will be the callback that we give to the
// trackbar.
//
void switch_callback( int position ) {
if( position == 0 ) {
switch_off_function();
} else {
switch_on_function();
}
}
//OK, OK, I ADDED READING A MOVIE AND USING THE "BUTTON" TO STOP AND GO
int main( int argc, char* argv[] ) {
IplImage *frame; //To hold movie images
CvCapture* g_capture = NULL;
if((argc < 2 )|| !(g_capture = cvCreateFileCapture( argv[1] ))){
printf("Failed to open %s/n",argv[1]);
return -1;
}
// Name the main window
//
cvNamedWindow( "Example4_2", 1 );
// Create the trackbar. We give it a name,
// and tell it the name of the parent window.
//
cvCreateTrackbar(
"Switch",
"Example4_2",
&g_switch_value,
1,
switch_callback
);
// This will just cause OpenCV to idle until
// someone hits the "Escape" key.
//
while( 1 ) {
if(g_switch_value){
frame = cvQueryFrame( g_capture );
if( !frame ) break;
}
cvShowImage( "Example4_2", frame);
if(cvWaitKey(10)==27 ) break;
}
//CLEAN UP
cvReleaseCapture( &g_capture );
cvDestroyWindow( "Example4_2" );
return(0);
}
- OpenCV学习——用Trackbar模仿一个按钮
- 学习OpenCV——金字塔分割(Trackbar)
- 【OPENCV学习】TrackBar学习
- OpenCV学习笔记-应用trackbar实现按钮功能
- 【Ubuntu+OpenCV】HighGUI之trackbar充当开关按钮--学习笔记【3】
- opencv基本图像处理——添加滑动条trackbar
- Python下使用OpenCV——使用Trackbar实现绘图板
- 学习OpenCV(六)TrackBar的使用
- CSS——模仿按钮1
- CSS——模仿按钮2(hover)
- OpenCV学习:创建Trackbar & 图像对比度、亮度值调整
- highgui基础 OpenCV trackbar
- OPENCV 各种模糊+Trackbar
- 【OpenCV】 TrackBar的使用
- OpenCV笔记:Trackbar
- opencv-Trackbar调色板
- OpenCV实践之路——TrackBar调整图像的亮度和对比度(OpenCV1和OpenCV2两种版本)
- OpenCV 创建Trackbar 轨迹条
- Perl语言学习笔记2
- ClientDataSet 经典
- Apache配置
- OpenCV学习——摄像头显示、录像、拍照程序
- 权限设计数据库结构表
- OpenCV学习——用Trackbar模仿一个按钮
- OpenCV学习——Highgui演示-简单绘制矩形
- 狮子那一份the lions share
- out of the box的含义和翻译
- IT技术图书之《敏捷无敌》当小说看 你信吗?
- Unix® Shell Programming读书笔记1
- Unix® Shell Programming读书笔记2
- Unix® Shell Programming读书笔记3
- Unix® Shell Programming读书笔记4(END)