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