00001 #ifndef brct_epi_reconstructor_h_
00002 #define brct_epi_reconstructor_h_
00003
00004 #if defined(_MSC_VER) && ( _MSC_VER > 1000 )
00005 #pragma once
00006 #endif // _MSC_VER > 1000
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 #include <vcl_vector.h>
00036 #include <vnl/vnl_double_2.h>
00037 #include <vnl/vnl_double_3.h>
00038 #include <vnl/vnl_double_3x3.h>
00039 #include <vnl/vnl_double_3x4.h>
00040 #include <vnl/vnl_vector_fixed.h>
00041 #include <vnl/vnl_matrix_fixed.h>
00042 #include <vnl/vnl_matrix.h>
00043 #include <vdgl/vdgl_digital_curve_sptr.h>
00044 #include <bugl/bugl_gaussian_point_2d.h>
00045 #include <vgl/vgl_point_2d.h>
00046 #include <vgl/vgl_point_3d.h>
00047 #include <bugl/bugl_curve_3d.h>
00048
00049 class brct_epi_reconstructor
00050 {
00051 public:
00052
00053
00054 void write_results(const char* fname);
00055 vgl_point_2d<double> get_cur_epipole() const;
00056
00057 vcl_vector<vnl_matrix<double> > get_back_projection() const;
00058
00059
00060 vnl_matrix<double> get_predicted_curve();
00061 vnl_double_3 get_next_motion(vnl_double_3 v);
00062 vcl_vector<vgl_point_2d<double> > get_pre_observes();
00063 vcl_vector<vgl_point_2d<double> > get_cur_observes();
00064 vcl_vector<vgl_point_2d<double> > get_next_observes();
00065
00066 vcl_vector<vgl_point_2d<double> > get_joe_pre_observes();
00067 vcl_vector<vgl_point_2d<double> > get_joe_cur_observes();
00068 vcl_vector<vgl_point_2d<double> > get_joe_next_observes();
00069
00070
00071 vcl_vector<vgl_point_3d<double> > get_local_pts();
00072 bugl_curve_3d get_curve_3d();
00073
00074
00075 void read_data(const char* fname);
00076
00077
00078 vcl_vector<vdgl_digital_curve_sptr> read_track_file(char* fname);
00079
00080
00081
00082 void init();
00083 void init_epipole(double x, double y);
00084 void inc();
00085 vnl_double_2 projection(const vnl_double_3x4 &P, const vnl_double_3 &X);
00086
00087
00088
00089 brct_epi_reconstructor();
00090 brct_epi_reconstructor(const char* fname);
00091 virtual ~brct_epi_reconstructor();
00092
00093
00094 void add_track(vcl_vector<vdgl_digital_curve_sptr> const& track);
00095
00096
00097 void print_track(const int track_index, const int frame);
00098
00099
00100 void print_motion_array();
00101 protected:
00102
00103 vcl_vector<double> read_timestamp_file(char* fname);
00104
00105
00106 double matched_point_prob(vnl_double_2& z, vnl_double_2& z_pred);
00107
00108
00109 vnl_matrix_fixed<double, 6, 6> get_transit_matrix(int i, int j);
00110
00111
00112 void update_confidence();
00113
00114
00115 void update_observes(const vnl_double_3x4 &P, int iframe);
00116 void update_observes_joe(int iframe);
00117 void init_velocity();
00118
00119
00120 vnl_matrix_fixed<double, 2, 6> get_H_matrix(vnl_double_3x4 &P, vnl_double_3 &Y);
00121
00122
00123 vnl_double_3x4 get_projective_matrix(const vnl_double_3 &v) const;
00124
00125 void init_covariant_matrix();
00126 void init_cam_intrinsic();
00127 void init_state_3d_estimation();
00128 void init_transit_matrix();
00129
00130
00131 bool match_point(vdgl_digital_curve_sptr const& dc,
00132 bugl_gaussian_point_2d<double>& p0,
00133 double grad_angle,
00134 bugl_gaussian_point_2d<double>& p);
00135
00136 vcl_vector<bugl_gaussian_point_2d<double> >
00137 get_cur_joe_observes(int frame);
00138 private:
00139
00140 bugl_curve_3d curve_3d_;
00141
00142 vcl_vector<double> prob_;
00143
00144
00145 vcl_vector<vcl_vector<bugl_gaussian_point_2d<double> > > observes_;
00146
00147
00148 vcl_vector<vcl_vector<vcl_vector<bugl_gaussian_point_2d<double> > > > joe_observes_;
00149
00150
00151 vcl_vector<vcl_vector<double> > grad_angles_;
00152
00153
00154 vcl_vector<double> time_tick_;
00155
00156
00157 vcl_vector<vcl_vector<vdgl_digital_curve_sptr> > tracks_;
00158
00159
00160 vcl_vector<vnl_double_3> motions_;
00161
00162
00163 int cur_pos_;
00164 int queue_size_;
00165 int num_points_;
00166
00167
00168 int memory_size_;
00169
00170
00171 vnl_vector_fixed<double, 6> X_;
00172
00173
00174 vnl_matrix_fixed<double, 6, 6> Q_;
00175
00176
00177 vnl_matrix_fixed<double, 6, 2> G_;
00178
00179
00180 vnl_matrix_fixed<double, 2, 2> R_;
00181
00182
00183 vnl_matrix_fixed<double, 6, 6> Q0_;
00184
00185
00186 vnl_double_2* e_;
00187
00188
00189 vnl_double_3x3 K_;
00190
00191
00192 static const double large_num_;
00193
00194 bool debug_;
00195 };
00196
00197 #endif // brct_epi_reconstructor_h_