00001
00002
00003 #ifndef _VIEWS_MANAGER_HPP
00004 #define _VIEWS_MANAGER_HPP
00005
00006 #include "geom/t3d.hpp"
00007 #include "geom/t3dPointTools.hpp"
00008 #include "geom/Declarations.hpp"
00009 #include "camera/cameraContainer.hpp"
00010 #include "bundler/view.hpp"
00011 #include "jmath/jblas.hpp"
00012 #include "jmath/linearLeastSquares.hpp"
00013
00014 namespace jafar {
00015
00016 namespace bundler {
00017
00026 class ViewsManager {
00027 private:
00029 std::string m_camCalibFile;
00031 jafar::camera::CameraType m_camType;
00033 jafar::camera::CameraContainer m_camContainer;
00035 int startImageIndex;
00037 std::map<int, geom::T3D*> m_toOriginReferences;
00039 std::vector<jafar::bundler::View*> views;
00041 jblas::mat pixMatrix;
00043 jblas::mat posMatrix;
00045 jblas::mat dirMatrix;
00047 jblas::mat a;
00049 jblas::vec b;
00051 jmath::LinearLeastSquares lls;
00053 jblas::vec3 center;
00055 double error;
00057 int first, last, step;
00059 void setCameraModel();
00060
00061 protected:
00063 View* viewFromImage(const int& _imgIndex,
00064 const jblas::vec2& _pixel);
00066 View* viewFromData(const int& _imgIndex,
00067 const jblas::vec2& _pixel,
00068 const jblas::vec3& _position,
00069 const jblas::vec3& _direction);
00070
00071 public:
00072 ViewsManager();
00073
00074 ViewsManager(const std::string& camCalibFile,
00075 const jafar::camera::CameraType& camType = jafar::camera::MONO) :
00076 m_camCalibFile(camCalibFile),
00077 m_camType(camType)
00078 {
00079 m_camContainer.setType(camType);
00080 setCameraModel();
00081 }
00082
00083 ViewsManager(const std::string& camCalibFile,
00084 const jafar::camera::CameraType& camType,
00085 const std::map<int, geom::T3D*>& toOriginReferences) :
00086 m_camCalibFile(camCalibFile),
00087 m_camType(camType),
00088 m_toOriginReferences(toOriginReferences)
00089 {
00090 m_camContainer.setType(camType);
00091 setCameraModel();
00092 }
00093
00094 ~ViewsManager();
00096 void setCamera(const camera::CameraType& camType,
00097 const std::string& camCalibFile);
00098 void setToOrigineReferences (const std::map<int, geom::T3D*>& toOriginReferences);
00100 std::string camCalibFile() const;
00102 std::vector<jafar::bundler::View*> viewsList();
00105 void loadViews(std::list<jblas::vec2> _pixelList,
00106 std::list<int> _indexList);
00108 void printViews();
00110 void clearViews();
00113 void insertNewView(const int& _imgIndex,
00114 const jblas::vec2& _pixel,
00115 const jblas::vec3& _position = jblas::zero_vec(3),
00116 const jblas::vec3& _direction = jblas::zero_vec(3),
00117 const jblas::vec2& _size = jblas::zero_vec(2));
00122 void solve();
00124 jblas::vec3 solution() const;
00127
00129 void insertToOriginReference(const int& index,
00130 geom::T3D* sensorToOrigin);
00132 std::map<int, geom::T3D *> toOriginReferences() const;
00134 geom::T3D* refByIndex(const int& index) const;
00137 double selectRay();
00139 void computeReprojectionError();
00141 double reprojectionError();
00142 };
00143
00144 }
00145
00146 }
00147
00148 #endif