00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __CAMERA_H
00029 #define __CAMERA_H
00030
00031 #include <libthjc/geometry.h>
00032 #include <libthjc/vector3d.h>
00033 #include <libthjc/matrix.h>
00034
00035
00036
00037 #include <list>
00038 using namespace std;
00039
00040
00041 typedef enum { CAM_LEFT, CAM_RIGHT } CAM_ID;
00042
00043
00044 class CalibrationPair
00045 {
00046 public:
00047 double x;
00048 double y;
00049 double X;
00050 double Y;
00051 double Z;
00052 };
00053
00054
00055 class Camera
00056 {
00057 public:
00058
00059 Camera() : T(3,1), R(3,3), K(3,3) , P(3,4), RT(4,4), PFull(4,4), BPFull(4,4) {Pairs=NULL;WorkingPairs=NULL;};
00060
00061
00062 int width, height;
00063
00064 double Ncx;
00065 double Nfx;
00066 double dx;
00067 double dy;
00068 double Cx;
00069 double Cy;
00070
00071
00072 double sx;
00073 double sy;
00074 Matrix T;
00075 Matrix R;
00076 Matrix K;
00077 Matrix P;
00078 Matrix RT;
00079 double f;
00080 double kappa1;
00081 Matrix PFull;
00082 Matrix BPFull;
00083
00084 unsigned int NumPairs;
00085 CalibrationPair * WorkingPairs;
00086 CalibrationPair * Pairs;
00087
00088
00089 Camera& operator= (const Camera &rhs)
00090 {
00091
00092
00093
00094 width = rhs.width;
00095 height = rhs.height;
00096 return *this;
00097 }
00098
00099
00100 double GetTx() const;
00101 double GetTy() const;
00102 double GetTz() const;
00103 double GetRx() const;
00104 double GetRy() const;
00105 double GetRz() const;
00106
00107 void SetTx(double Value);
00108 void SetTy(double Value);
00109 void SetTz(double Value);
00110 void SetRx(double Value);
00111 void SetRy(double Value);
00112 void SetRz(double Value);
00113
00114 double GetFocalDistance() const;
00115 void SetFocalDistance(double Value);
00116
00117 void UpdateRT();
00118
00119
00120 list<Point2D> GetProjectedPoints() const;
00121 Matrix GetErrMatrix() const;
00122 Matrix Get3DErrMatrix() const;
00123
00124
00125
00126 Ray GetBPRay(Point2D Point) const;
00127 Point2D PixelToPoint(Point2D Pixel) const;
00128 Vector3D Point2DToPoint3D(Point2D Point) const;
00129 Vector3D CRFToWRF(Vector3D Point3D_CRF) const;
00130
00131 Point2D ProjectPoint(Vector3D WorldPoint) const;
00132
00133 public:
00134 void CalcApprox_f_Tz ();
00135 bool LoadIntrinsicParams (char *fileName);
00136 void Calibrate(list<CalibrationPair> &points);
00137 list<CalibrationPair> & LoadCalibPairs (list<Point2D> &points, list<CalibrationPair> &pairs, char * CalibFile);
00138 void Calibrate_SA();
00139 private:
00140
00141 };
00142
00143 Matrix solve_RPY_transform (Matrix R);
00144 Matrix apply_RPY_transform ( double R, double P, double Y);
00145
00146
00147 #endif