]> rtime.felk.cvut.cz Git - frescor/frsh.git/blob - demo/dcamera/show_video_v4l_main.c
fda9cf5366c2b2c2ecda2385b16abebb741c45c6
[frescor/frsh.git] / demo / dcamera / show_video_v4l_main.c
1 /*==========================================================================
2   $Id$
3   show_video_v4l_main.c: Main routine for capturing video using GLUT and V4L.
4   Written by Naoyuki Ichimura, AIST, 2001.
5 ==========================================================================*/
6
7 #include "show_video_v4l.h"
8
9 int extract_skin_color; /* global variable for enabling image processing */
10
11 #include <camera.h>
12 //int main( int argc , char *argv[] )
13 void* video_thread(void* args)
14 {
15     video_args_t *video_args = (video_args_t*) args;
16     int argc = video_args->argc;
17     char** argv;
18     
19     argv = video_args->argv;    
20     static char window_title[1024]="Video Capture";
21     int i,j;
22     int video_input;
23
24     double zoom_rate;   /* for zooming */
25
26 /*======= Set option =========================================*/
27     zoom_rate = DEFAULT_ZOOM_RATE;
28     //video_input = S_VIDEO;
29     video_input = 0;
30     extract_skin_color = 0;
31     for( i = j = 1 ; i < argc ; i++ ) {
32         if( argv[i][0] == '-' || argv[i][0] == '/' ) {
33             switch( argv[i][1] ) {
34               case 'z':
35                 zoom_rate = atof(&argv[i][2]);
36                 break;
37
38               case 'v':
39                 video_input = atoi(&argv[i][2]);
40                 break;
41
42               case 's':
43                 extract_skin_color = 1;
44                 break;
45
46               default:
47                 break;
48
49             }
50         } else {
51             argv[j++] = argv[i];
52         }
53     }
54     argc = j;
55
56 /*======= Initialize GLUT ====================================*/
57     glutInit( &argc , argv );
58     glutInitDisplayMode( GLUT_RGBA); /* enable double buffering of video board */
59
60 /*======= Initialize window ==================================*/
61     glutInitWindowPosition( INIT_WINDOW_POS_X , INIT_WINDOW_POS_Y );    /* initial window position */
62     glutInitWindowSize( (int)(zoom_rate*IMAGE_WIDTH_DS) , (int)(zoom_rate*IMAGE_HEIGHT_DS) );   /* set window size */
63     glutCreateWindow( window_title );   /* creat window with name */
64
65 /*======= Initialize projection ==============================*/
66     glOrtho( 0.0 , IMAGE_WIDTH_DS-1.0 , 0.0 , IMAGE_HEIGHT_DS , -1.0 , 1.0 );
67     glPixelZoom( zoom_rate , zoom_rate );
68
69 /*======= Initilize capture device ============================*/
70     //ShowVideoInitCaptureDevice( DEFAULT_DEVICE_NAME , video_input );
71
72 /*======= Initilize buffer ====================================*/
73     glClearColor( 0.0 , 0.0 , 0.0 , 0.0 );
74     glClear( GL_COLOR_BUFFER_BIT );
75     //glutSwapBuffers();
76     glFlush();
77
78 /*======= Register callback functions =========================*/
79     glutDisplayFunc( ShowVideoDisplayImage );
80     glutMouseFunc( ShowVideoMouseCheck );
81     //glutIdleFunc( ShowVideoCaptureImage );    /* global idle callback */
82     glutIdleFunc( ShowVideoIdle );      /* global idle callback */
83
84 /*======= Begin event loop ====================================*/
85     glutMainLoop();
86
87     exit(0);
88
89 }