Go to the documentation of this file.00001 
00002 #ifndef vmal_track_lines_h_
00003 #define vmal_track_lines_h_
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 #include <vcl_vector.h>
00019 #include <vxl_config.h>
00020 #include <vtol/vtol_edge_2d_sptr.h>
00021 #include <vmal/vmal_multi_view_data_edge_sptr.h>
00022 
00023 #include <vil1/vil1_image.h>
00024 #include <vil1/vil1_memory_image_of.h>
00025 
00026 #include <vnl/vnl_double_3x3.h>
00027 
00028 class vmal_track_lines
00029 {
00030  public:
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039   vmal_track_lines();
00040 
00041 
00042 
00043   virtual ~vmal_track_lines();
00044 
00045 
00046 
00047 
00048   void track_lines(const vcl_vector<vcl_vector<vtol_edge_2d_sptr>*>* fit_lines,
00049                    const vcl_vector<vcl_vector<vtol_edge_2d_sptr>*>* transformed_lines,
00050                    const vcl_vector<vil1_image> &images, const vcl_vector<vnl_double_3x3> &homo,
00051                    vmal_multi_view_data_edge_sptr matches);
00052 
00053 
00054 
00055 
00056 
00057 
00058   void sort_lines(vmal_multi_view_data_edge_sptr matches,
00059                   vmal_multi_view_data_edge_sptr sorted_matches);
00060 
00061 
00062 
00063 
00064 
00065 
00066   double lines_correlation(vtol_edge_2d_sptr line0,
00067                            vtol_edge_2d_sptr line1,
00068                            const vnl_double_3x3 & H,
00069                            vil1_memory_image_of<vxl_byte> &image0,
00070                            vil1_memory_image_of<vxl_byte> &image1);
00071 
00072  private:
00073 
00074   double seg_angle(vtol_edge_2d_sptr, vtol_edge_2d_sptr);
00075   bool belong(vtol_edge_2d_sptr, vtol_edge_2d_sptr);
00076   double dist(vtol_edge_2d_sptr, vtol_edge_2d_sptr);
00077 
00078 
00079 
00080 
00081 
00082 
00083   double project_point(double x0,double y0,
00084                        double ax,double ay,
00085                        double bx,double by,
00086                        double *x,double *y);
00087 
00088   int is_cur_best(vtol_edge_2d_sptr trans_line,vtol_edge_2d_sptr fitted_line,vtol_edge_2d_sptr other_line);
00089 
00090 
00091 
00092   vtol_edge_2d_sptr find_transfo(vtol_edge_2d_sptr line,
00093                                  vcl_vector<vtol_edge_2d_sptr>& fit_lines,
00094                                  const vcl_vector<vtol_edge_2d_sptr>& transformed_lines);
00095 
00096 
00097 
00098   void refine_line_at_min(vtol_edge_2d_sptr line0, vtol_edge_2d_sptr line1,
00099                           vtol_edge_2d_sptr &new_line0, vtol_edge_2d_sptr &new_line1,
00100                           const vnl_double_3x3 &H);
00101 
00102   void sort_a_pair_of_line(vtol_edge_2d_sptr line0,
00103                            vtol_edge_2d_sptr line1,
00104                            vtol_edge_2d_sptr &new_line0,
00105                            vtol_edge_2d_sptr &new_line1);
00106 
00107 
00108   void cost_function(vtol_edge_2d_sptr line0,
00109                      vtol_edge_2d_sptr t_line0,
00110                      vtol_edge_2d_sptr line1,
00111                      const vil1_image &image0, const vil1_image &image1,
00112                      const vnl_double_3x3 homo,
00113                      double &result);
00114 
00115   double theta_;
00116   double radius_;
00117 };
00118 
00119 #endif // vmal_track_lines_h_