00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #pragma once
00018
00019
00020
00021
00022
00023
00024 #include "tnt_array2d.h"
00025 #include "tnt_array2d_utils.h"
00026 #include "tnt_array1d_utils.h"
00027 #include "jama_svd.h"
00028 #include "jama_eig.h"
00029 #include "global.h"
00030
00031 #include <string.h>
00032 #include <stdio.h>
00033 #include <iostream>
00034 #include <sstream>
00035 using namespace std;
00036 using namespace TNT;
00037 using namespace JAMA;
00038
00039
00040 namespace Calibration{
00047 class Step1{
00048 friend class Step2;
00049 Array2D<double> M;
00050 Array2D<double> m;
00051 Array1D<double> w;
00052
00054 void homography();
00056 void tameR();
00058 void createRtFromA( Array2D<double> &A);
00060 Array1D<double> totalErrors(Array2D<double> A,Array1D<double> Win,Array1D<double> tin);
00062 Array1D<double> totalErrors(Array2D<double> A,Array1D<double> Win,Array1D<double> tin,double k1,double k2);
00064 static int fcn(void *p,int l, int n,const double *x, double *fvec, int iflag);
00065 public:
00067 void createRfromW();
00069 void updateRt(){
00070 for(int x=0;x<3;x++){
00071 Rt[x][0]=R[x][0];
00072 Rt[x][1]=R[x][1];
00073 Rt[x][2]=t[x];
00074 }
00075 }
00077 Array2D<double> R;
00079 Array2D<double> Rt;
00081 Array1D<double> t;
00083 Array2D<double> H;
00085 char name[500];
00092 Step1(Array2D<double> &M,Array2D<double> &m, const char *name)
00093 : w(3,0.0),R(3,3,0.0),Rt(3,3,0.0),t(3,0.0),H(3,3,0.0){
00094 this->M=M.copy();
00095 this->m=m.copy();
00096 strcpy(this->name,name);
00097 homography();
00098 };
00104 void getInfo(string &total){
00105 stringstream ss;
00106 string s;
00107 total=name;
00108 total+="\nR:\n";
00109 ss<<R[0][0]<<" "<<R[0][1]<<" "<<R[0][2]<<" "
00110 <<R[1][0]<<" "<<R[1][1]<<" "<<R[1][2]<<" "
00111 <<R[2][0]<<" "<<R[2][1]<<" "<<R[2][2]<<" ";
00112 for(int x=0;x<3;x++){
00113 ss>>s;
00114 total+= s + " ";
00115 ss>>s;
00116 total+= s + " ";
00117 ss>>s;
00118 total+= s + "\n";
00119 }
00120 ss<<t[0]<<" "<<t[1]<<" "<<t[2]<<" ";
00121 total+="T:\n";
00122 for(int x=0;x<3;x++){
00123 ss>>s;
00124 total+=s+'\n';
00125 }
00126
00127 }
00128 void updatePoints(Array2D<double> &m){
00129 this->m=m.copy();
00130 }
00131 };
00132 }
00133