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