Go to the documentation of this file.00001 #ifdef _WIN32
00002 # include <windows.h>
00003 #endif
00004 #include <stdio.h>
00005 #include <stdlib.h>
00006 #ifndef __APPLE__
00007 # include <GL/gl.h>
00008 # include <GL/glut.h>
00009 #else
00010 # include <OpenGL/gl.h>
00011 # include <GLUT/glut.h>
00012 #endif
00013 #include <AR/gsub.h>
00014 #include <AR/video.h>
00015 #include <AR/param.h>
00016 #include <AR/ar.h>
00017
00018
00019
00020
00021 char *vconf =
00022 #if defined(_WIN32)
00023 "Data\\WDM_camera_flipV.xml";
00024 #elif defined(__APPLE__)
00025 "";
00026 #elif defined(__linux)
00027 # if defined(AR_INPUT_GSTREAMER)
00028 "";
00029 # else
00030 "";
00031 # endif
00032 #else
00033 "";
00034 #endif
00035
00036 int xsize, ysize;
00037 int count = 0;
00038
00039 char *cparam_name = "Data/camera_para.dat";
00040 ARParam cparam;
00041
00042
00043 static void init(void);
00044 static void cleanup(void);
00045 static void keyEvent( unsigned char key, int x, int y);
00046 static void mainLoop(void);
00047
00048
00049 int main(int argc, char **argv)
00050 {
00051
00052 glutInit(&argc, argv);
00053
00054
00055 init();
00056
00057
00058 arVideoCapStart();
00059
00060
00061 argMainLoop( NULL, keyEvent, mainLoop );
00062
00063 return 0;
00064 }
00065
00066 static void keyEvent( unsigned char key, int x, int y)
00067 {
00068
00069 if( key == 0x1b ) {
00070 printf("*** %f (frame/sec)\n", (double)count/arUtilTimer());
00071 cleanup();
00072 exit(0);
00073 }
00074 }
00075
00076
00077 static void mainLoop(void)
00078 {
00079 ARUint8 *dataPtr;
00080
00081
00082 if( (dataPtr = (ARUint8 *)arVideoGetImage()) == NULL ) {
00083 arUtilSleep(2);
00084 return;
00085 }
00086 if( count == 0 ) arUtilTimerReset();
00087 count++;
00088
00089
00090 argDrawMode2D();
00091 argDispImage( dataPtr, 0,0 );
00092
00093
00094 arVideoCapNext();
00095
00096
00097 argSwapBuffers();
00098 }
00099
00100 static void init( void )
00101 {
00102 ARParam wparam;
00103
00104
00105 if( arVideoOpen( vconf ) < 0 ) exit(0);
00106
00107
00108 if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0);
00109 printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);
00110
00111
00112 if( arParamLoad(cparam_name, 1, &wparam) < 0 ) {
00113 printf("Camera parameter load error !!\n");
00114 exit(0);
00115 }
00116 arParamChangeSize( &wparam, xsize, ysize, &cparam );
00117
00118
00119 argInit( &cparam, 1.0, 0, 0, 0, 0 );
00120 }
00121
00122
00123 static void cleanup(void)
00124 {
00125 arVideoCapStop();
00126 arVideoClose();
00127 argCleanup();
00128 }