1 #ifndef rgrl_est_homography2d_h_
2 #define rgrl_est_homography2d_h_
3 
4 //:
5 // \file
6 // \author Charlene Tsai
7 // \date   Oct 2004
8 
9 #include <rgrl/rgrl_estimator.h>
10 
11 //: homography2D transform estimator
12 //
13 class rgrl_est_homography2d
14   : public rgrl_linear_estimator
15 {
16  public:
17   //: Default constructor
18   //
19   rgrl_est_homography2d( double condition_num_thrd = 0.0 );
20 
21   //: Estimates a quadratic transform.
22   //
23   // The return pointer is to a rgrl_trans_quadratic object.
24   //
25   // \sa rgrl_estimator::estimate
26   //
27   rgrl_transformation_sptr
28   estimate( rgrl_set_of<rgrl_match_set_sptr> const& matches,
29             rgrl_transformation const& cur_transform ) const override;
30 
31   //: Estimates a quadratic transform.
32   //
33   // The return pointer is to a rgrl_trans_quadratic object.
34   //
35   // \sa rgrl_estimator::estimate
36   //
37   // The estimation technique is the normalized DLT (Direct Linear
38   // Transformation) algorithm.
39   rgrl_transformation_sptr
40   estimate( rgrl_match_set_sptr matches,
41             rgrl_transformation const& cur_transform ) const override;
42 
43   //: Type of transformation estimated by this estimator.
44   const std::type_info& transformation_type() const override;
45 
46   // Defines type-related functions
47   rgrl_type_macro( rgrl_est_homography2d, rgrl_linear_estimator );
48 
49  private:
50   bool normalize( rgrl_set_of<rgrl_match_set_sptr> const& matches,
51                   std::vector< vnl_vector<double> >& norm_froms,
52                   std::vector< vnl_vector<double> >& norm_tos,
53                   std::vector< double >& wgts,
54                   double& from_scale,
55                   double& to_scale,
56                   vnl_vector< double > & from_center,
57                   vnl_vector< double > & to_center ) const;
58   void estimate_covariance( const std::vector< vnl_vector<double> >& norm_froms,
59                             const std::vector< vnl_vector<double> >& norm_tos,
60                             const std::vector< double >& wgts,
61                             double from_scale,
62                             double to_scale,
63                             vnl_matrix<double>& covar ) const;
64 
65  private:
66   double condition_num_thrd_;
67 };
68 
69 #endif
70