/* --------------------------------------------------------------------- */ /* - GenCalib.C - */ /* --------------------------------------------------------------------- */ /* - Some necessary includes... - */ /* --------------------------------------------------------------------- */ #include "calibration.h" /* --------------------------------------------------------------------- */ /* - Global variables and structures... - */ /* --------------------------------------------------------------------- */ int result; int i,j, r; int N=2,M=3; float X[MAX], Y[MAX], Z[MAX]; int ImX[MAX], ImY[MAX]; float areal=0.0; FILE *fp1, *fp2; main() { printf ("starting camera calibration/matrix generation program \n"); if ((fp1 = fopen( "CALIBPTS","w")) == NULL ) printf("cant open file: matrixA \n" ); if ((fp2 = fopen( "M","w")) == NULL ) printf("cant open file: M \n" ); printf ("what is M (rows) the number of data points ? \n"); N = 7; printf ("M (rows): "); scanf("%d", &M); printf("\n N: %d M: %d\n", N, M); fprintf (fp2, "%4d", M); fflush( fp2 ); for (i=1;i<=M;i++) { printf ("what is X[%d]: ",i); scanf("%f", &X[i]); printf ("what is Y[%d]: ",i); scanf("%f", &Y[i]); printf ("what is Z[%d]: ",i); scanf("%f", &Z[i]); printf ("what is image point X -> ImX[%d]: ",i); scanf("%d", &ImX[i]); printf ("what is image point Y -> ImY[%d]: ",i); scanf("%d", &ImY[i]); } printf ("this is the data\n"); for (i=1;i<=M;i++) { printf ("X[%d]: %f ",i, X[i]); printf ("Y[%d]: %f ",i, Y[i]); printf ("Z[%d]: %f ",i, Z[i]); printf ("xm -> ImX[%d]: %d ",i, ImX[i]); printf ("ym -> ImY[%d]: %d\n",i, ImY[i]); } do { printf ("what row to replace? type 0 for done or no\n"); scanf("%d", &i); if (i != 0) { printf ("what is X[%d]: ",i); scanf("%f", &X[i]); printf ("what is Y[%d]: ",i); scanf("%f", &Y[i]); printf ("what is Z[%d]: ",i); scanf("%f", &Z[i]); printf ("what is image point X -> ImX[%d]: ",i); scanf("%d", &ImX[i]); printf ("what is image point Y -> ImY[%d]: ",i); scanf("%d", &ImY[i]); printf ("NOW ...this is the data\n"); for (j=1;j<=M;j++) { printf ("X[%d]: %f ",j, X[j]); printf ("Y[%d]: %f ",j, Y[j]); printf ("Z[%d]: %f ",j, Z[j]); printf ("xm -> ImX[%d]: %d ",j, ImX[j]); printf ("ym -> ImY[%d]: %d\n",j, ImY[j]); } } } while (i != 0); for (i=1;i<= M;i++) { fprintf (fp1, "%15f", X[i]); fflush( fp1 ); fprintf (fp1, "%15f", Y[i]); fflush( fp1 ); fprintf (fp1, "%15f", Z[i]); fflush( fp1 ); fprintf (fp1, "%6d", ImX[i]); fflush( fp1 ); fprintf (fp1, "%6d \n", ImY[i]); fflush( fp1 ); } if ( fp1 != NULL ) if (r = fclose( fp1 ) != 0) printf ("fp1 didnt close properly \n"); if ( fp2 != NULL ) if (r = fclose( fp2 ) != 0) printf ("fp2 didnt close properly \n"); } /* end main function */ #ifdef ROGER #endif