[artoolkit-commits] artoolkit/util/videoTest videoTest.c,1.2,1.3
Optical marker tracking and overlay for augmented reality.
Brought to you by:
philip_lamb
From: Philip L. <phi...@us...> - 2005-04-13 06:13:12
|
Update of /cvsroot/artoolkit/artoolkit/util/videoTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29190 Modified Files: videoTest.c Log Message: Fix for glutInit bug in OSX libARgsub. Index: videoTest.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/util/videoTest/videoTest.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** videoTest.c 25 Nov 2004 22:44:54 -0000 1.2 --- videoTest.c 13 Apr 2005 06:13:02 -0000 1.3 *************** *** 1,116 **** ! #ifdef _WIN32 ! # include <windows.h> ! #endif ! #include <stdio.h> ! #include <stdlib.h> ! #ifndef __APPLE__ ! # include <GL/gl.h> ! # include <GL/glut.h> ! #else ! # include <OpenGL/gl.h> ! # include <GLUT/glut.h> ! #endif ! #include <AR/gsub.h> ! #include <AR/video.h> ! #include <AR/param.h> ! #include <AR/ar.h> ! ! /*****************************************************************************/ ! // modified by Thomas Pintaric, Vienna University of Technology ! ! #ifdef _WIN32 ! char *vconf = "flipV"; // see video.h for a list of supported parameters ! #else ! char *vconf = ""; ! #endif ! /*****************************************************************************/ ! ! int xsize, ysize; ! int count = 0; ! ! char *cparam_name = "Data/camera_para.dat"; ! ARParam cparam; ! ! ! static void init(void); ! static void cleanup(void); ! static void keyEvent( unsigned char key, int x, int y); ! static void mainLoop(void); ! ! ! int main(int argc, char **argv) ! { ! //initialize applications ! init(); ! ! //start video capture ! arVideoCapStart(); ! ! //start the main event loop ! argMainLoop( NULL, keyEvent, mainLoop ); ! ! return 0; ! } ! ! static void keyEvent( unsigned char key, int x, int y) ! { ! /* quit if the ESC key is pressed */ ! if( key == 0x1b ) { ! printf("*** %f (frame/sec)\n", (double)count/arUtilTimer()); ! cleanup(); ! exit(0); ! } ! } ! ! /* main loop */ ! static void mainLoop(void) ! { ! ARUint8 *dataPtr; ! ! /* grab a video frame */ ! if( (dataPtr = (ARUint8 *)arVideoGetImage()) == NULL ) { ! arUtilSleep(2); ! return; ! } ! if( count == 0 ) arUtilTimerReset(); ! count++; ! ! /*draw the video*/ ! argDrawMode2D(); ! argDispImage( dataPtr, 0,0 ); ! ! /* capture the next video frame */ ! arVideoCapNext(); ! ! /*swap the graphics buffers*/ ! argSwapBuffers(); ! } ! ! static void init( void ) ! { ! ARParam wparam; ! ! /* open the video path */ ! if( arVideoOpen( vconf ) < 0 ) exit(0); ! /* find the size of the window */ ! if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0); ! printf("Image size (x,y) = (%d,%d)\n", xsize, ysize); ! ! /* set the initial camera parameters */ ! if( arParamLoad(cparam_name, 1, &wparam) < 0 ) { ! printf("Camera parameter load error !!\n"); ! exit(0); ! } ! arParamChangeSize( &wparam, xsize, ysize, &cparam ); ! ! /* open the graphics window */ ! argInit( &cparam, 1.0, 0, 0, 0, 0 ); ! } ! ! /* cleanup function called when program exits */ ! static void cleanup(void) ! { ! arVideoCapStop(); ! arVideoClose(); ! argCleanup(); ! } --- 1,119 ---- ! #ifdef _WIN32 ! # include <windows.h> ! #endif ! #include <stdio.h> ! #include <stdlib.h> ! #ifndef __APPLE__ ! # include <GL/gl.h> ! # include <GL/glut.h> ! #else ! # include <OpenGL/gl.h> ! # include <GLUT/glut.h> ! #endif ! #include <AR/gsub.h> ! #include <AR/video.h> ! #include <AR/param.h> ! #include <AR/ar.h> ! ! /*****************************************************************************/ ! // modified by Thomas Pintaric, Vienna University of Technology ! ! #ifdef _WIN32 ! char *vconf = "flipV"; // see video.h for a list of supported parameters ! #else ! char *vconf = ""; ! #endif ! /*****************************************************************************/ ! ! int xsize, ysize; ! int count = 0; ! ! char *cparam_name = "Data/camera_para.dat"; ! ARParam cparam; ! ! ! static void init(void); ! static void cleanup(void); ! static void keyEvent( unsigned char key, int x, int y); ! static void mainLoop(void); ! ! ! int main(int argc, char **argv) ! { ! //initialize applications ! #ifdef __APPLE__ ! glutInit(&argc, argv); ! #endif ! init(); ! ! //start video capture ! arVideoCapStart(); ! ! //start the main event loop ! argMainLoop( NULL, keyEvent, mainLoop ); ! ! return 0; ! } ! ! static void keyEvent( unsigned char key, int x, int y) ! { ! /* quit if the ESC key is pressed */ ! if( key == 0x1b ) { ! printf("*** %f (frame/sec)\n", (double)count/arUtilTimer()); ! cleanup(); ! exit(0); ! } ! } ! ! /* main loop */ ! static void mainLoop(void) ! { ! ARUint8 *dataPtr; ! ! /* grab a video frame */ ! if( (dataPtr = (ARUint8 *)arVideoGetImage()) == NULL ) { ! arUtilSleep(2); ! return; ! } ! if( count == 0 ) arUtilTimerReset(); ! count++; ! ! /*draw the video*/ ! argDrawMode2D(); ! argDispImage( dataPtr, 0,0 ); ! ! /* capture the next video frame */ ! arVideoCapNext(); ! ! /*swap the graphics buffers*/ ! argSwapBuffers(); ! } ! ! static void init( void ) ! { ! ARParam wparam; ! ! /* open the video path */ ! if( arVideoOpen( vconf ) < 0 ) exit(0); ! /* find the size of the window */ ! if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0); ! printf("Image size (x,y) = (%d,%d)\n", xsize, ysize); ! ! /* set the initial camera parameters */ ! if( arParamLoad(cparam_name, 1, &wparam) < 0 ) { ! printf("Camera parameter load error !!\n"); ! exit(0); ! } ! arParamChangeSize( &wparam, xsize, ysize, &cparam ); ! ! /* open the graphics window */ ! argInit( &cparam, 1.0, 0, 0, 0, 0 ); ! } ! ! /* cleanup function called when program exits */ ! static void cleanup(void) ! { ! arVideoCapStop(); ! arVideoClose(); ! argCleanup(); ! } |