[artoolkit-commits] artoolkit/util/calib_distortion calib_dist.c,1.10,1.11
Optical marker tracking and overlay for augmented reality.
Brought to you by:
philip_lamb
From: Philip L. <phi...@us...> - 2005-09-22 00:44:53
|
Update of /cvsroot/artoolkit/artoolkit/util/calib_distortion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3278 Modified Files: calib_dist.c Log Message: Step 3 of cleanup. Index: calib_dist.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/util/calib_distortion/calib_dist.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** calib_dist.c 15 Sep 2005 00:52:03 -0000 1.10 --- calib_dist.c 22 Sep 2005 00:44:45 -0000 1.11 *************** *** 113,121 **** static void Reshape(int w, int h); static void Display(void); ! static void draw_warp_line( double a, double b , double c ); static void draw_line(void); ! static void draw_line2( double *x, double *y, int num ); ! static void draw_warp_line( double a, double b , double c ); ! static void print_comment( int status ); int main(int argc, char *argv[]) --- 113,121 ---- static void Reshape(int w, int h); static void Display(void); ! static void draw_warp_line(double a, double b , double c); static void draw_line(void); ! static void draw_line2(double *x, double *y, int num); ! static void draw_warp_line(double a, double b , double c); ! static void print_comment(int status); int main(int argc, char *argv[]) *************** *** 193,211 **** // Allocate space for a clipping image (luminance only). arMalloc(gClipImage, unsigned char, gXsize * gYsize); - - return (TRUE); - } - static int videoCleanup(void) - { - arVideoCapStop(); - arVideoClose(); return (TRUE); } static void grabImage(void) { // Processing a new image. ! // Copy the current image to saved image buffer. ! if (!gARTImage) return; gPatt.loop_num++; if ((gPatt.arglSettings[gPatt.loop_num-1] = arglSetupForCurrentContext()) == NULL) { --- 193,208 ---- // Allocate space for a clipping image (luminance only). arMalloc(gClipImage, unsigned char, gXsize * gYsize); return (TRUE); } static void grabImage(void) { + ARUint8 *image; + // Processing a new image. ! // Copy an image to saved image buffer. ! do { ! image = arVideoGetImage(); ! } while (image == NULL); gPatt.loop_num++; if ((gPatt.arglSettings[gPatt.loop_num-1] = arglSetupForCurrentContext()) == NULL) { *************** *** 215,219 **** arglDistortionCompensationSet(gPatt.arglSettings[gPatt.loop_num-1], FALSE); arMalloc((gPatt.savedImage)[gPatt.loop_num-1], unsigned char, gXsize*gYsize*AR_PIX_SIZE); ! memcpy((gPatt.savedImage)[gPatt.loop_num-1], gARTImage, gXsize*gYsize*AR_PIX_SIZE); printf("Grabbed image %d.\n", gPatt.loop_num); arMalloc(gPatt.point[gPatt.loop_num-1], CALIB_COORD_T, gPatt.h_num*gPatt.v_num); --- 212,216 ---- arglDistortionCompensationSet(gPatt.arglSettings[gPatt.loop_num-1], FALSE); arMalloc((gPatt.savedImage)[gPatt.loop_num-1], unsigned char, gXsize*gYsize*AR_PIX_SIZE); ! memcpy((gPatt.savedImage)[gPatt.loop_num-1], image, gXsize*gYsize*AR_PIX_SIZE); printf("Grabbed image %d.\n", gPatt.loop_num); arMalloc(gPatt.point[gPatt.loop_num-1], CALIB_COORD_T, gPatt.h_num*gPatt.v_num); *************** *** 249,254 **** if (gStatus == 0) { // Cancelled grabbing. ! // Live video will not be needed from here on, so cleanup. ! videoCleanup(); if (gPatt.loop_num == 0) { // No images with all features identified, so quit. --- 246,251 ---- if (gStatus == 0) { // Cancelled grabbing. ! // Live video will not be needed from here on. ! arVideoCapStop(); if (gPatt.loop_num == 0) { // No images with all features identified, so quit. *************** *** 286,291 **** int ssx, ssy, eex, eey; int i, j, k; ! ! if (button == GLUT_RIGHT_BUTTON) { eventCancel(); } else if (button == GLUT_LEFT_BUTTON) { --- 283,288 ---- int ssx, ssy, eex, eey; int i, j, k; ! ! if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN) { eventCancel(); } else if (button == GLUT_LEFT_BUTTON) { *************** *** 327,331 **** } } else if (state == GLUT_UP) { ! if (gStatus == 1 && point_num < gPatt.h_num*gPatt.v_num) { // Drag for rubber-bounding of a feature has finished. Begin identification // of center of white region in gClipImage. --- 324,331 ---- } } else if (state == GLUT_UP) { ! if (gStatus == 1 ! && gDragStartX != -1 && gDragStartY != -1 ! && gDragEndX != -1 && gDragEndY != -1 ! && point_num < gPatt.h_num*gPatt.v_num) { // Drag for rubber-bounding of a feature has finished. Begin identification // of center of white region in gClipImage. *************** *** 339,344 **** p = gClipImage; k = 0; ! for( j = 0; j < (eey-ssy+1); j++ ) { ! for( i = 0; i < (eex-ssx+1); i++ ) { gPatt.point[gPatt.loop_num-1][point_num].x_coord += i * *p; gPatt.point[gPatt.loop_num-1][point_num].y_coord += j * *p; --- 339,344 ---- p = gClipImage; k = 0; ! for (j = 0; j < (eey-ssy+1); j++) { ! for (i = 0; i < (eex-ssx+1); i++) { gPatt.point[gPatt.loop_num-1][point_num].x_coord += i * *p; gPatt.point[gPatt.loop_num-1][point_num].y_coord += j * *p; *************** *** 347,351 **** } } ! if( k != 0 ) { gPatt.point[gPatt.loop_num-1][point_num].x_coord /= k; gPatt.point[gPatt.loop_num-1][point_num].y_coord /= k; --- 347,351 ---- } } ! if (k != 0) { gPatt.point[gPatt.loop_num-1][point_num].x_coord /= k; gPatt.point[gPatt.loop_num-1][point_num].y_coord /= k; *************** *** 442,447 **** --- 442,452 ---- static void Quit(void) { + if (gClipImage) { + free(gClipImage); + gClipImage = NULL; + } if (gArglSettings) arglCleanup(gArglSettings); if (gWin) glutDestroyWindow(gWin); + arVideoClose(); exit(0); } *************** *** 511,518 **** static void endOrtho2D(void) { - glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); } --- 516,523 ---- static void endOrtho2D(void) { glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); + glPopMatrix(); } *************** *** 527,530 **** --- 532,537 ---- glClear(GL_COLOR_BUFFER_BIT); glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + glDisable(GL_TEXTURE_2D); beginOrtho2D(); *************** *** 533,536 **** --- 540,544 ---- arglDispImage(gARTImage, &gARTCparam, 1.0, gArglSettings); // zoom = 1.0. arVideoCapNext(); + gARTImage = NULL; } else if (gStatus == 1) { *************** *** 541,555 **** x = gPatt.point[gPatt.loop_num-1][i].x_coord; y = gPatt.point[gPatt.loop_num-1][i].y_coord; ! glColor3f( 1.0, 0.0, 0.0 ); glBegin(GL_LINES); ! glVertex2f( x-10, (gYsize-1)-y ); ! glVertex2f( x+10, (gYsize-1)-y ); ! glVertex2f( x, (gYsize-1)-(y-10) ); ! glVertex2f( x, (gYsize-1)-(y+10) ); glEnd(); } // Draw the current mouse drag clipping area. ! if (gDragStartX != -1 && gDragStartY != -1) { if (gDragStartX < gDragEndX) { ssx = gDragStartX; eex = gDragEndX; } else { ssx = gDragEndX; eex = gDragStartX; } --- 549,564 ---- x = gPatt.point[gPatt.loop_num-1][i].x_coord; y = gPatt.point[gPatt.loop_num-1][i].y_coord; ! glColor3f(1.0f, 0.0f, 0.0f); glBegin(GL_LINES); ! glVertex2d(x-10.0, (GLdouble)(gYsize-1)-y); ! glVertex2d(x+10.0, (GLdouble)(gYsize-1)-y); ! glVertex2d(x, (GLdouble)(gYsize-1)-(y-10.0)); ! glVertex2d(x, (GLdouble)(gYsize-1)-(y+10.0)); glEnd(); } // Draw the current mouse drag clipping area. ! if (gDragStartX != -1 && gDragStartY != -1 ! && gDragEndX != -1 && gDragEndY != -1) { if (gDragStartX < gDragEndX) { ssx = gDragStartX; eex = gDragEndX; } else { ssx = gDragEndX; eex = gDragStartX; } *************** *** 559,563 **** if (gClipImage) { glPixelZoom(1.0f, -1.0f); // ARToolKit bitmap 0.0 is at upper-left, OpenGL bitmap 0.0 is at lower-left. ! glRasterPos2f((GLfloat)ssx, (GLfloat)gYsize-1-ssy); glDrawPixels(eex-ssx+1, eey-ssy+1, GL_LUMINANCE, GL_UNSIGNED_BYTE, gClipImage); } --- 568,573 ---- if (gClipImage) { glPixelZoom(1.0f, -1.0f); // ARToolKit bitmap 0.0 is at upper-left, OpenGL bitmap 0.0 is at lower-left. ! glRasterPos2f((GLfloat)(ssx), (GLfloat)(gYsize-1-ssy)); ! glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glDrawPixels(eex-ssx+1, eey-ssy+1, GL_LUMINANCE, GL_UNSIGNED_BYTE, gClipImage); } *************** *** 565,572 **** glColor3f(0.0f, 0.0f, 1.0f); glBegin(GL_LINE_LOOP); ! glVertex2f(gDragStartX, (gYsize-1)-gDragStartY); ! glVertex2f(gDragEndX, (gYsize-1)-gDragStartY); ! glVertex2f(gDragEndX, (gYsize-1)-gDragEndY); ! glVertex2f(gDragStartX, (gYsize-1)-gDragEndY); glEnd(); #endif --- 575,582 ---- glColor3f(0.0f, 0.0f, 1.0f); glBegin(GL_LINE_LOOP); ! glVertex2i(gDragStartX, (gYsize-1)-gDragStartY); ! glVertex2i(gDragEndX, (gYsize-1)-gDragStartY); ! glVertex2i(gDragEndX, (gYsize-1)-gDragEndY); ! glVertex2i(gDragStartX, (gYsize-1)-gDragEndY); glEnd(); #endif *************** *** 579,588 **** x = gPatt.point[check_num][i].x_coord; y = gPatt.point[check_num][i].y_coord; ! glColor3f( 1.0, 0.0, 0.0 ); glBegin(GL_LINES); ! glVertex2f( x-10, (gYsize-1)-y ); ! glVertex2f( x+10, (gYsize-1)-y ); ! glVertex2f( x, (gYsize-1)-(y-10) ); ! glVertex2f( x, (gYsize-1)-(y+10) ); glEnd(); } --- 589,598 ---- x = gPatt.point[check_num][i].x_coord; y = gPatt.point[check_num][i].y_coord; ! glColor3f(1.0f, 0.0f, 0.0f); glBegin(GL_LINES); ! glVertex2d(x-10.0, (GLdouble)(gYsize-1)-y); ! glVertex2d(x+10.0, (GLdouble)(gYsize-1)-y); ! glVertex2d(x, (GLdouble)(gYsize-1)-(y-10.0)); ! glVertex2d(x, (GLdouble)(gYsize-1)-(y+10.0)); glEnd(); } *************** *** 716,735 **** case 0: printf("Press mouse button to grab first image,\n"); ! printf("or press [esc] to quit.\n"); break; case 1: printf("Press mouse button and drag mouse to rubber-bound features (%d x %d),\n", gPatt.h_num, gPatt.v_num); ! printf("or press [esc] to cancel rubber-bounding & retry grabbing.\n"); break; case 2: printf("Press mouse button to save feature positions,\n"); ! printf("or press [esc] to discard feature positions & retry grabbing.\n"); break; case 4: printf("Press mouse button to grab next image,\n"); ! printf("or press [esc] to calculate distortion parameter.\n"); break; case 5: ! printf("Press [esc] to calculate distortion parameter.\n"); break; } --- 726,745 ---- case 0: printf("Press mouse button to grab first image,\n"); ! printf("or press right mouse button or [esc] to quit.\n"); break; case 1: printf("Press mouse button and drag mouse to rubber-bound features (%d x %d),\n", gPatt.h_num, gPatt.v_num); ! printf("or press right mouse button or [esc] to cancel rubber-bounding & retry grabbing.\n"); break; case 2: printf("Press mouse button to save feature positions,\n"); ! printf("or press right mouse button or [esc] to discard feature positions & retry grabbing.\n"); break; case 4: printf("Press mouse button to grab next image,\n"); ! printf("or press right mouse button or [esc] to calculate distortion parameter.\n"); break; case 5: ! printf("Press right mouse button or [esc] to calculate distortion parameter.\n"); break; } |