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 #ifndef RECONSTRUCTION_H
00023 #define RECONSTRUCTION_H
00024 
00025 #include <iostream>
00026 #include <stdio.h>
00027 #include <string.h>
00028 #include <stdlib.h>
00029 #define _USE_MATH_DEFINES
00030 #include <math.h>
00031 
00032 #include "matcher.h"
00033 #include "matrix.h"
00034 
00035 class Reconstruction {
00036 
00037 public:
00038   
00039   
00040   Reconstruction ();
00041   
00042   
00043   ~Reconstruction ();
00044   
00045   
00046   struct point3d {
00047     float x,y,z;
00048     point3d () {}
00049     point3d (float x,float y,float z) : x(x),y(y),z(z) {}
00050   };
00051 
00052   
00053   
00054   
00055   void setCalibration (FLOAT f,FLOAT cu,FLOAT cv);
00056   
00057   
00058   
00059   
00060   
00061   
00062   
00063   
00064   
00065   
00066   void update (std::vector<Matcher::p_match> p_matched,Matrix Tr,int32_t point_type=1,int32_t min_track_length=2,double max_dist=30,double min_angle=2);
00067   
00068   
00069   std::vector<point3d> getPoints() { return points; }
00070 
00071 private:
00072   
00073   struct point2d {
00074     float u,v;
00075     point2d () {}
00076     point2d (float u,float v) : u(u),v(v) {}
00077   };
00078   
00079   struct track {
00080     std::vector<point2d> pixels;
00081     int32_t first_frame;
00082     int32_t last_frame;
00083     int32_t last_idx;
00084   };
00085   
00086   enum result { UPDATED, FAILED, CONVERGED };
00087   
00088   bool    initPoint(const track &t,point3d &p);
00089   bool    refinePoint(const track &t,point3d &p);
00090   double  pointDistance(const track &t,point3d &p);
00091   double  rayAngle(const track &t,point3d &p);
00092   int32_t pointType(const track &t,point3d &p);
00093   result  updatePoint(const track &t,point3d &p,const FLOAT &step_size,const FLOAT &eps);
00094   void    computeObservations(const std::vector<point2d> &p);
00095   bool    computePredictionsAndJacobian(const std::vector<Matrix>::iterator &P_begin,const std::vector<Matrix>::iterator &P_end,point3d &p);
00096   void    testJacobian();
00097   
00098   
00099   Matrix K,Tr_cam_road;
00100   
00101   std::vector<track>   tracks;
00102   std::vector<Matrix>  Tr_total;
00103   std::vector<Matrix>  Tr_inv_total;
00104   std::vector<Matrix>  P_total;
00105   std::vector<point3d> points;
00106   
00107   FLOAT *J;                     
00108   FLOAT *p_observe,*p_predict;  
00109 
00110 };
00111 
00112 #endif // RECONSTRUCTION_H