/********************************************************************************
*         CS 791E Programming Assignment # 3
*              Canny Algorithm Application
*
*  
*  Name:   calibration.cpp
*  Usage:  1). make
*          2). make <file-number> .....
*  Autor:  Beifang Yi
*  Date:   4/13/03
*
*
********************************************************************************/


#include "cv.h"
#include "highgui.h"

#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream.h>
#include <fstream.h>
#include <unistd.h>
#include <list>

#include "calibCam.h"

int main( int argc, char** argv )
{
  int i, j, k;
  int fileNums[15];
  int key;

  CalibCam cam1;

  CalibCam::totalNumImages = 15;

  if (argc < 2) {
    cout << " To run the program, please type: "<<endl;
    cout << " ./calibration 1, 2, 5...."<<endl;
    exit(0);
  }
  
  for (i = 0; i < argc - 1; i++)
    fileNums[i] = atoi(argv[i + 1]);

  cam1.initialize(argc -1, 96, fileNums);
  cam1.getImageSize(fileNums);

  cam1.directCalibration();

  /*
  //cam1.getExtrinsicParams(1);
  cout<<endl;cam1.printCameraParams();
  CvPoint3D64d p3 = {cam1.objectPoints[0].x, 
		     cam1.objectPoints[0].y,
		     cam1.objectPoints[0].z};
  cam1.world2pixel(p3);

  */

  cout<<endl<<" input file number for accuracy test ?  "; int whichOne;
  cin>>whichOne;
  cam1.accuracyE(whichOne);  
  //display the effect and save the image
  cam1.printCameraParams();
  //cam1.displayErrorInImage(whichOne);


  cout<<endl<<" input file number for projection test ?  ";
  cin>>whichOne;
  cam1.projectionE(whichOne);
  //display the effect and save the image
  cam1.printCameraParams();
  cam1.displayErrorInImage(whichOne);

  //cam1.projMatCalibration();

  key = cvWaitKey(0);
  while (key != 32) {
    key = cvWaitKey(0);
  }
}


