Go to the documentation of this file.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
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #ifndef __ATAN_CAMERA_H
00045 #define __ATAN_CAMERA_H
00046
00047 #include <TooN/TooN.h>
00048 #include <cmath>
00049 using namespace TooN;
00050 #include <cvd/vector_image_ref.h>
00051 #include <gvars3/gvars3.h>
00052
00053
00054 #define NUMTRACKERCAMPARAMETERS 5
00055
00056 class CameraCalibrator;
00057 class CalibImage;
00058
00059
00060
00061
00062
00063
00064
00065
00066 class ATANCamera {
00067 public:
00068 ATANCamera(TooN::Vector<5> params);
00069
00070
00071 void SetImageSize(Vector<2> v2ImageSize);
00072 inline void SetImageSize(CVD::ImageRef irImageSize) {SetImageSize(vec(irImageSize));};
00073 inline Vector<2> GetImageSize() {return mvImageSize;};
00074 void RefreshParams();
00075
00076
00077 Vector<2> Project(const Vector<2>& camframe);
00078 inline Vector<2> Project(CVD::ImageRef ir) { return Project(vec(ir)); }
00079 Vector<2> UnProject(const Vector<2>& imframe);
00080 inline Vector<2> UnProject(CVD::ImageRef ir) { return UnProject(vec(ir)); }
00081
00082 Vector<2> UFBProject(const Vector<2>& camframe);
00083 Vector<2> UFBUnProject(const Vector<2>& camframe);
00084 inline Vector<2> UFBLinearProject(const Vector<2>& camframe);
00085 inline Vector<2> UFBLinearUnProject(const Vector<2>& fbframe);
00086
00087 Matrix<2,2> GetProjectionDerivs();
00088
00089 inline bool Invalid() { return mbInvalid;}
00090 inline double LargestRadiusInImage() { return mdLargestRadius; }
00091 inline double OnePixelDist() { return mdOnePixelDist; }
00092
00093
00094 inline Vector<2> ImplaneTL();
00095 inline Vector<2> ImplaneBR();
00096
00097
00098 Matrix<4> MakeUFBLinearFrustumMatrix(double near, double far);
00099
00100
00101 double PixelAspectRatio() { return mvFocal[1] / mvFocal[0];}
00102
00103
00104
00105 static const Vector<NUMTRACKERCAMPARAMETERS> mvDefaultParams;
00106
00107 protected:
00108 GVars3::gvar3<Vector<NUMTRACKERCAMPARAMETERS> > mgvvCameraParams;
00109
00110 Matrix<2, NUMTRACKERCAMPARAMETERS> GetCameraParameterDerivs();
00111 void UpdateParams(Vector<NUMTRACKERCAMPARAMETERS> vUpdate);
00112 void DisableRadialDistortion();
00113
00114
00115 Vector<2> mvLastCam;
00116 Vector<2> mvLastIm;
00117 Vector<2> mvLastDistCam;
00118 double mdLastR;
00119 double mdLastDistR;
00120 double mdLastFactor;
00121 bool mbInvalid;
00122
00123
00124 double mdLargestRadius;
00125 double mdMaxR;
00126 double mdOnePixelDist;
00127 double md2Tan;
00128 double mdOneOver2Tan;
00129 double mdW;
00130 double mdWinv;
00131 double mdDistortionEnabled;
00132 Vector<2> mvCenter;
00133 Vector<2> mvFocal;
00134 Vector<2> mvInvFocal;
00135 Vector<2> mvImageSize;
00136 Vector<2> mvUFBLinearFocal;
00137 Vector<2> mvUFBLinearInvFocal;
00138 Vector<2> mvUFBLinearCenter;
00139 Vector<2> mvImplaneTL;
00140 Vector<2> mvImplaneBR;
00141
00142
00143 inline double rtrans_factor(double r)
00144 {
00145 if(r < 0.001 || mdW == 0.0)
00146 return 1.0;
00147 else
00148 return (mdWinv* atan(r * md2Tan) / r);
00149 };
00150
00151
00152 inline double invrtrans(double r)
00153 {
00154 if(mdW == 0.0)
00155 return r;
00156 return(tan(r * mdW) * mdOneOver2Tan);
00157 };
00158
00159 std::string msName;
00160
00161 friend class CameraCalibrator;
00162 friend class CalibImage;
00163 };
00164
00165
00166 inline Vector<2> ATANCamera::UFBLinearProject(const Vector<2>& camframe)
00167 {
00168 Vector<2> v2Res;
00169 v2Res[0] = camframe[0] * mvUFBLinearFocal[0] + mvUFBLinearCenter[0];
00170 v2Res[1] = camframe[1] * mvUFBLinearFocal[1] + mvUFBLinearCenter[1];
00171 return v2Res;
00172 }
00173
00174 inline Vector<2> ATANCamera::UFBLinearUnProject(const Vector<2>& fbframe)
00175 {
00176 Vector<2> v2Res;
00177 v2Res[0] = (fbframe[0] - mvUFBLinearCenter[0]) * mvUFBLinearInvFocal[0];
00178 v2Res[1] = (fbframe[1] - mvUFBLinearCenter[1]) * mvUFBLinearInvFocal[1];
00179 return v2Res;
00180 }
00181
00182
00183 #endif
00184