00001
00002 #ifndef vmal_rectifier_h_
00003 #define vmal_rectifier_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <vcl_vector.h>
00024
00025 #include <vmal/vmal_multi_view_data_vertex_sptr.h>
00026 #include <vmal/vmal_multi_view_data_edge_sptr.h>
00027 #include <vil/vil_image_view.h>
00028
00029 #include <mvl/TriTensor.h>
00030
00031 class vmal_rectifier
00032 {
00033 public:
00034
00035
00036
00037
00038 vmal_rectifier();
00039
00040
00041
00042
00043 vmal_rectifier(vmal_multi_view_data_vertex_sptr mvd_vertex,
00044 vmal_multi_view_data_edge_sptr mvd_edge,
00045 int ima_height, int ima_width);
00046
00047 vmal_rectifier(vcl_vector< vnl_vector<double> >* pts0,
00048 vcl_vector< vnl_vector<double> >* pts1,
00049 int ima_height, int ima_width);
00050
00051 ~vmal_rectifier();
00052
00053 void rectification_matrix(vnl_double_3x3& H0,
00054 vnl_double_3x3& H1);
00055
00056 void set_tritensor(TriTensor &tri);
00057
00058 void compute_joint_epipolar_transform_new (
00059 vnl_double_3* points0,
00060 vnl_double_3* points1,
00061 int numpoints,
00062 vnl_double_3x3 &H0, vnl_double_3x3 &H1,
00063 int in_height, int in_width,
00064 int &out_height, int &out_width,
00065 double sweeti, double sweetj,
00066 bool affine );
00067
00068 void compute_initial_joint_epipolar_transforms (
00069 vnl_double_3* points0,
00070 vnl_double_3* points1,
00071 int numpoints,
00072 vnl_double_3x3 &H0, vnl_double_3x3 &H1,
00073 double sweeti, double sweetj,
00074 bool affine );
00075
00076 int compute_initial_joint_epipolar_transforms (
00077 const vnl_double_3x3 &Q,
00078 double ci, double cj,
00079 vnl_double_3x3 &H0,
00080 vnl_double_3x3 &H1);
00081
00082 vnl_double_3x3 matching_transform (
00083 const vnl_double_3x3 &Q,
00084 const vnl_double_3x3 &H1);
00085
00086 void factor_Q_matrix_SR (
00087 const vnl_double_3x3 &Q,
00088 vnl_double_3x3 &R,
00089 vnl_double_3x3 &S);
00090
00091 vnl_double_3x3 affine_correction (
00092 vnl_double_3* points0,
00093 vnl_double_3* points1,
00094 int numpoints,
00095 const vnl_double_3x3 &H0,
00096 const vnl_double_3x3 &H1);
00097
00098 void apply_affine_correction (
00099 vnl_double_3* points0,
00100 vnl_double_3* points1,
00101 int numpoints,
00102 vnl_double_3x3 &H0, vnl_double_3x3 &H1);
00103
00104 void rectify_rotate90 (
00105 int &height, int &width,
00106 vnl_double_3x3 &H0,
00107 vnl_double_3x3 &H1);
00108
00109 void conditional_rectify_rotate180 (
00110 vnl_double_3x3 &H0,
00111 vnl_double_3x3 &H1);
00112
00113 void resample (vnl_double_3x3 H0, vnl_double_3x3 H1,
00114 vil_image_view<vxl_byte> imgL,
00115 vil_image_view<vxl_byte> imgR);
00116
00117 vil_image_view<vxl_byte>* GetRectifiedImageLeft() {return rectL;}
00118 vil_image_view<vxl_byte>* GetRectifiedImageRight() {return rectR;}
00119
00120 private:
00121 vnl_double_3* lines0_p_;
00122 vnl_double_3* lines0_q_;
00123 vnl_double_3* lines1_p_;
00124 vnl_double_3* lines1_q_;
00125
00126 vnl_double_3* points0_;
00127 vnl_double_3* points1_;
00128 int numpoints_;
00129
00130 int height_;
00131 int width_;
00132 TriTensor tritensor_;
00133 vnl_double_3x3 F12_;
00134 vcl_vector<vnl_double_3> epipoles_;
00135 bool is_f_compute_;
00136 vnl_double_3x3 H0_,H1_;
00137
00138 vil_image_view<vxl_byte>* rectL;
00139 vil_image_view<vxl_byte>* rectR;
00140
00141 };
00142
00143 #endif // vmal_rectifier_h_