[artoolkit-commits] artoolkit/examples/twoView twoView.c,1.8,1.9
Optical marker tracking and overlay for augmented reality.
Brought to you by:
philip_lamb
From: Philip L. <phi...@us...> - 2005-07-29 23:23:07
|
Update of /cvsroot/artoolkit/artoolkit/examples/twoView In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23859 Modified Files: twoView.c Log Message: Cleanup drawing code. Index: twoView.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/twoView/twoView.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** twoView.c 28 Jul 2005 21:58:06 -0000 1.8 --- twoView.c 29 Jul 2005 23:22:59 -0000 1.9 *************** *** 5,9 **** * Press '?' while running for help. * ! * Copyright (c) 2004-2004 Philip Lamb (PRL) ph...@ed.... All rights reserved. * * Rev Date Who Changes --- 5,9 ---- * Press '?' while running for help. * ! * Copyright (c) 2004-2005 Philip Lamb (PRL) ph...@ed.... All rights reserved. * * Rev Date Who Changes *************** *** 71,74 **** --- 71,75 ---- AR2VideoParamT *ARTVideo; // Video parameters ARUint8 *ARTImage; // Most recent image. + int ARTThreshhold; // Threshold for marker detection. long callCountMarkerDetect; // Frames received. double patt_trans[3][4]; // Marker transformation. *************** *** 88,92 **** // ARToolKit globals. static long gCallCountGetImage = 0; - static int gARTThreshhold = 100; static int gPatt_id; static double gPatt_width = 80.0; --- 89,92 ---- *************** *** 191,222 **** } - // Function to clean up and then exit. Will be - // installed by atexit() and called when program exit()s. - static void Quit(void) - { - int i; - - fprintf(stderr, "Quitting...\n"); - - // OpenGL per-context cleanup. - for (i = 0; i < gContextsActiveCount; i++) { - if (gContextsActive[i].apiContextIndex) { - glutSetWindow(gContextsActive[i].apiContextIndex); - arglCleanup(gContextsActive[i].arglSettings); - DrawCubeCleanup(i); - glutDestroyWindow(gContextsActive[i].apiContextIndex); - gContextsActive[i].apiContextIndex = 0; - } - ar2VideoCapStop(gContextsActive[i].ARTVideo); - ar2VideoClose(gContextsActive[i].ARTVideo); - } - gContextsActiveCount = 0; - - // Library finals (in reverse order to inits.) - DrawCubeFinal(); - } - // Sets up fields ARTVideo, ARTCparam of gContextsActive[0] through gContextsActive[cameraCount - 1]. ! static int demoARSetupCameras(const int cameraCount, const unsigned char *cparam_names[], char *vconfs[]) { int i; --- 191,196 ---- } // Sets up fields ARTVideo, ARTCparam of gContextsActive[0] through gContextsActive[cameraCount - 1]. ! static int demoARSetupCameras(const int cameraCount, const char *cparam_names[], char *vconfs[]) { int i; *************** *** 245,248 **** --- 219,223 ---- fprintf(stderr, "*** Camera %d parameter ***\n", i + 1); arParamDisp(&(gContextsActive[i].ARTCparam)); + gContextsActive[i].ARTThreshhold = 100; // Start the video capture for this camera. *************** *** 256,260 **** } ! static int demoARSetupMarker(const unsigned char *patt_name, int *patt_id) { --- 231,235 ---- } ! static int demoARSetupMarker(const char *patt_name, int *patt_id) { *************** *** 325,328 **** --- 300,329 ---- } + // Function to clean up and then exit. Will be + // installed by atexit() and called when program exit()s. + static void Quit(void) + { + int i; + + fprintf(stdout, "Quitting...\n"); + + // OpenGL per-context cleanup. + for (i = 0; i < gContextsActiveCount; i++) { + if (gContextsActive[i].apiContextIndex) { + glutSetWindow(gContextsActive[i].apiContextIndex); + arglCleanup(gContextsActive[i].arglSettings); + DrawCubeCleanup(i); + glutDestroyWindow(gContextsActive[i].apiContextIndex); + gContextsActive[i].apiContextIndex = 0; + } + ar2VideoCapStop(gContextsActive[i].ARTVideo); + ar2VideoClose(gContextsActive[i].ARTVideo); + } + gContextsActiveCount = 0; + + // Library finals (in reverse order to inits.) + DrawCubeFinal(); + } + static void Keyboard(unsigned char key, int x, int y) { *************** *** 407,411 **** // Grab a video frame. if ((image = ar2VideoGetImage(gContextsActive[i].ARTVideo)) != NULL) { ! gContextsActive[i].ARTImage = image; gContextsActive[i].callCountMarkerDetect++; // Increment ARToolKit FPS counter. --- 408,413 ---- // Grab a video frame. if ((image = ar2VideoGetImage(gContextsActive[i].ARTVideo)) != NULL) { ! gContextsActive[i].ARTImage = image; // Save the fetched image. ! gContextsActive[i].patt_found = FALSE; // Invalidate any previous detected markers. gContextsActive[i].callCountMarkerDetect++; // Increment ARToolKit FPS counter. *************** *** 413,417 **** // Detect the markers in the video frame. ! if (arDetectMarkerLite(gContextsActive[i].ARTImage, gARTThreshhold, &marker_info, &marker_num) < 0) { exit(-1); } --- 415,419 ---- // Detect the markers in the video frame. ! if (arDetectMarkerLite(gContextsActive[i].ARTImage, gContextsActive[i].ARTThreshhold, &marker_info, &marker_num) < 0) { exit(-1); } *************** *** 469,472 **** --- 471,477 ---- } + // + // The function is called when a window needs redrawing. + // static void DisplayPerContext(const int drawContextIndex) { *************** *** 487,492 **** // Projection transformation. - glMatrixMode(GL_PROJECTION); arglCameraFrustum(&(gContextsActive[drawContextIndex].ARTCparam), VIEW_DISTANCE_MIN, VIEW_DISTANCE_MAX, p); glLoadMatrixd(p); glMatrixMode(GL_MODELVIEW); --- 492,497 ---- // Projection transformation. arglCameraFrustum(&(gContextsActive[drawContextIndex].ARTCparam), VIEW_DISTANCE_MIN, VIEW_DISTANCE_MAX, p); + glMatrixMode(GL_PROJECTION); glLoadMatrixd(p); glMatrixMode(GL_MODELVIEW); *************** *** 498,502 **** //none ! // ARToolKit supplied distance in millimetres, but I want OpenGL to work in metres. arglCameraView(gContextsActive[drawContextIndex].patt_trans, m, VIEW_SCALEFACTOR); glLoadMatrixd(m); --- 503,507 ---- //none ! // ARToolKit supplied distance in millimetres, but I want OpenGL to work in my units. arglCameraView(gContextsActive[drawContextIndex].patt_trans, m, VIEW_SCALEFACTOR); glLoadMatrixd(m); *************** *** 504,509 **** // All other lighting and geometry goes here. DrawCube(drawContextIndex); - - gContextsActive[drawContextIndex].patt_found = FALSE; } // patt_found --- 509,512 ---- *************** *** 541,545 **** int i; char windowTitle[32] = {0}; ! const unsigned char *cparam_names[] = { // Camera parameter names. "Data/camera_para.dat", "Data/camera_para.dat", --- 544,548 ---- int i; char windowTitle[32] = {0}; ! const char *cparam_names[] = { // Camera parameter names. "Data/camera_para.dat", "Data/camera_para.dat", *************** *** 557,561 **** #endif }; ! const unsigned char *patt_name = "Data/patt.hiro"; --- 560,564 ---- #endif }; ! const char *patt_name = "Data/patt.hiro"; |