CameraParameters.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00026 #ifndef __CAM_PARS_H_
00027 #define __CAM_PARS_H_
00028 
00029 #include <R3Arma.h>
00030 #include <LogTrace.h>
00031 
00032 namespace MipBaselib{
00036 class CameraPar3DArma{
00039  
00040  private:
00042   Decimal             _width;
00044   Decimal             _widthPixel;
00046   Decimal             _height;
00048   Decimal             _heightPixel;
00050   Decimal             _focal;
00052   Decimal             _focalPixel;
00054   Decimal             _fovW;
00056   Decimal             _fovH;
00058   Roto3DHomoArma         _rotoCamFromW;
00060   arma::Mat<Decimal>::fixed<3,3> _calibMatrix;
00061  public:
00062   
00064   CameraPar3DArma();
00065   
00074   CameraPar3DArma(const Decimal info1, const Decimal info2, const Decimal info3,int opt, const Position2DArma &pp=Position2DArma(), const Decimal sk = 0.0, const Roto3DHomoArma &rcfw=Roto3DHomoArma(IDENTITY_ARMA_MATRIX),CanonicalCameraArmaMatrix cc=PIXEL_CAMERA_ARMA_MATRIX);
00075   
00077   CameraPar3DArma(const CameraPar3DArma& rhs);
00078   
00082   void _findMetricInfo(const Decimal info, int opt);
00083   
00088   void _findPixelInfo(const Decimal info, int opt, const Position2DArma &pp=Position2DArma());
00089   
00092   Position2DArma getPrincipalPoint() const;
00093   
00096   Decimal getPrincipalPointX() const;
00097   
00100   Decimal getPrincipalPointY() const;
00101   
00104   void setPrincipalPoint(const Position2DArma &pp);
00105   
00109   void setPrincipalPoint(const Decimal &ppx, const Decimal &ppy);
00110   
00113   void setPrincipalPointX(const Decimal x);
00114   
00117   void setPrincipalPointY(const Decimal y);
00118   
00120   CameraPar3DArma& operator=(const CameraPar3DArma& rhs);
00121   
00124   Decimal getWidthMetric() const;
00125   
00128   void setWidthMetric(const Decimal w);
00129   
00132   Decimal getWidthPixel() const;
00133   
00136   void setWidthPixel(const Decimal w);
00137   
00140   Decimal getHeightMetric() const;
00141   
00144   void setHeightMetric(const Decimal h);
00145   
00148   Decimal getHeightPixel() const;
00149   
00152   void setHeightPixel(const Decimal h);
00153   
00156   Decimal getFocalMetric() const;
00157   
00160   void setFocalMetric(const Decimal f);
00161   
00164   Decimal getFocalPixel() const;
00165   
00169   void setFocalPixel(const Decimal f, bool update=true);
00170   
00173   Decimal getFovW() const;
00174   
00177   Angle getFovWAngle() const;
00178   
00181   void setFovW(const Decimal fov);
00182   
00185   void setFovWAngle(const Angle fov);
00186   
00189   Decimal getFovH() const;
00190   
00193   Angle getFovHAngle() const;
00194   
00197   void setFovH(const Decimal fov);
00198   
00201   void setFovHAngle(const Angle fov);
00202   
00205   Roto3DHomoArma getRotoCamFromW() const;
00206   
00209   Roto3DHomoArma* getRotoCamFromWPointer();
00210   
00213   Roto3DArma getRotationCamFromW() const;
00214   
00217   Position3DArma getTranslationCamFromW() const;
00218   
00221   void setRotoCamFromWPointer(const Roto3DHomoArma &roto);
00222   
00225   arma::Mat<Decimal>::fixed<3,3> getCalibMatrix() const;
00226   
00229   arma::Mat<Decimal>::fixed<3,3> getCalibInvMatrix() const;
00230   
00233   arma::Mat<Decimal>::fixed<3,3>* getCalibMatrixPointer();
00234   
00237   void setCalibMatrix(arma::Mat<Decimal>::fixed<3,3> calib);
00238   
00242   void setCalibMatrix(const Decimal f);
00243   
00247   void setCalibMatrix(const Decimal f, const Position2DArma &pp);
00248   
00253   void setCalibMatrix(const Decimal f, const Decimal ppx, const Decimal ppy);
00254   
00257   Decimal getSkew() const;
00258   
00261   void setSkew(const Decimal skew);
00262   
00265   string print(int opt=0);
00266 };
00267 
00271 class CameraCCDPar3DArma : public MIPObject{
00274  
00277  
00278  private:
00280   Decimal             _widthPx;
00282   Decimal             _heightPx;
00284   Decimal             _focalPx;
00285   
00286   // NOTE: I do not know if the relationship -> fovW = 2*tg(width/(2*f)) is valid anymore, so I delete fovW and fovH for a while
00288   Roto3DHomoArma         _rotoCamFromW;
00290   bool validCalMat;
00292   arma::Mat<Decimal>::fixed<3,3> _calibMatrix;
00294   arma::Mat<Decimal>::fixed<3,3> _invCalibMatrix;
00296   Decimal             _mX;
00298   Decimal             _mY;
00300   Position2DArma         _pp;
00301   
00304 //   Decimal             _skew;
00305   
00306  public:
00308   CameraCCDPar3DArma();
00309   
00319   CameraCCDPar3DArma(const Decimal f, const Decimal mx, const Decimal my, const Decimal w = -1.0, const Decimal h = -1.0, const Decimal sk = 0.0, const Position2DArma &pp=Position2DArma(), const Roto3DHomoArma &rcfw=Roto3DHomoArma(IDENTITY_ARMA_MATRIX));
00320   
00329   CameraCCDPar3DArma(const Decimal &alphax, const Decimal &alphay, const Decimal w = -1.0, const Decimal h = -1.0, const Decimal sk = -1.0, const Position2DArma &pp=Position2DArma(), const Roto3DHomoArma &rcfw=Roto3DHomoArma(IDENTITY_ARMA_MATRIX));
00330   
00332   CameraCCDPar3DArma(const CameraCCDPar3DArma& rhs);
00333   
00335   CameraCCDPar3DArma& operator=(const CameraCCDPar3DArma& rhs);
00336   
00337   // Get methods: the key idea is that some field of this class might or not be initialized in the constructor.
00338   // Then, if not, it's initialized with a negative value (that are not reasonable for the field of this class). 
00339   // If it is so, the get method will return false;
00340   // otherwise it will return true if a valid value is set
00341   
00345   bool getFocalPixel(Decimal &f);
00346   
00350   bool getWidthPixel(Decimal &w);
00351   
00355   bool getHeightPixel(Decimal &h);
00356   
00360   bool getCalibMatrix(arma::Mat<Decimal>::fixed<3,3>& cm);
00361   
00365   arma::Mat<Decimal>::fixed<3,3>* getCalibMatrixPointer(bool &ret);
00366   
00370   bool getCalibInvMatrix(arma::Mat<Decimal>::fixed<3,3>& cm);
00371   
00375   bool getCalibMatrixPointer(arma::Mat<Decimal>::fixed<3,3>* &cm);
00376   
00380   bool getCalibInvMatrixPointer(arma::Mat<Decimal>::fixed<3,3>* &cm);
00381   
00385   arma::Mat<Decimal>::fixed<3,3>* getCalibInvMatrixPointer(bool &ret);
00386   
00390   bool getMx(Decimal &mx);
00391   
00395   bool getMy(Decimal &my);
00396   
00400   bool getFocalMx(Decimal &fmx);
00401   
00405   bool getFocalMy(Decimal &fmy);
00406   
00410   bool getPrincipalPointMxMy(Position2DArma &ppmx);
00411   
00415   bool getPrincipalPointMxX(Decimal &ppmxx);
00416   
00420   bool getPrincipalPointMyY(Decimal &ppmxy);
00421   
00425   bool getSkew(Decimal &s);
00426   
00427   // Direct get methods: NOTE: no check about validity of data
00428   
00431   Decimal getFocalPixel() const;
00432   
00435   Decimal getWidthPixel() const;
00436   
00439   Decimal getHeightPixel() const;
00440   
00443   Position2DArma getPrincipalPointPixel() const;
00444   
00447   Decimal getPrincipalPointPixelX() const;
00448   
00451   Decimal getPrincipalPointPixelY() const;
00452   
00455   arma::Mat<Decimal>::fixed<3,3> getCalibMatrix() const;
00456   
00459   arma::Mat<Decimal>::fixed<3,3> getCalibInvMatrix() const;
00460   
00463   arma::Mat<Decimal>::fixed<3,3>* getCalibMatrixPointer();
00464   
00467   arma::Mat<Decimal>::fixed<3,3>* getCalibInvMatrixPointer();
00468   
00471   Decimal getMx();
00472   
00475   Decimal getMy();
00476   
00479   Decimal getFocalMx() const;
00480   
00483   Decimal getFocalMy() const;
00484   
00487   Position2DArma getPrincipalPointMx() const;
00488   
00491   Decimal getPrincipalPointMxX() const;
00492   
00495   Decimal getPrincipalPointMyY() const;
00496   
00499   Decimal getSkew() const;
00500   
00501   // Set methods
00502   
00506   void setFocalPixel(const Decimal &f,int opt = 2);
00507   
00510   void setWidthPixel(const Decimal &w);
00511   
00515   void setHeightPixel(const Decimal &h);
00516   
00520   void setSkew(const Decimal &s,int opt = 2);
00521   
00525   void setPrincipalPoint(const Position2DArma &pp,int opt = 2);
00526   
00530   void setMx(const Decimal &mx, int opt=2);
00531   
00535   void setMy(const Decimal &my, int opt=2);
00536   
00541   void setMxMy(const Decimal &mx, const Decimal &my, int opt=2);
00542   
00545   void updateCalibrationMatrix();
00546   
00547   string getObjectName() const {
00548    return string("CameraCCDPar3DArma");
00549   }
00550   
00553   string print(int opt = 0);
00554 };
00555 
00556 }
00557 
00558 #endif

Generated on Mon Feb 20 07:01:07 2017 for MIP by  doxygen 1.5.6