1 // This is oxl/mvl/FManifoldProject.h
2 #ifndef FManifoldProject_h_
3 #define FManifoldProject_h_
4 //:
5 // \file
6 // \brief Fast 2-view Hartley-Sturm
7 //
8 //    FManifoldProject is a class which allows repeated fast application of the
9 //    manifold projection ("Hartley-Sturm") correction to points in two views.
10 //
11 // \author
12 //     Andrew W. Fitzgibbon, Oxford RRG, 22 Jan 97
13 //
14 // \verbatim
15 //  Modifications
16 //   AWF 030897 Moved to MViewBasics
17 //   210598 AWF Return squared error, as \sqrt(|x - p|^2 + |x' - p'|^2) is meaningless.
18 //   AWF Handle affine F.
19 //   P. Torr added in a check for multiple solutions
20 //     this might be necessary to flag the instance when a particular correspondence
21 //     might have several possible closest points all near to each other,
22 //     indicating high structure variability and high curvature in the F manifold.
23 //     These points should be treated with care, but are interesting as
24 //     they are in loci of high information.
25 //   22 Jun 2003 - Peter Vanroose - added vgl_homg_point_2d interface
26 // \endverbatim
27 //-----------------------------------------------------------------------------
28 
29 #include <vnl/vnl_double_3x3.h>
30 #include <vnl/vnl_double_4x4.h>
31 #include <vnl/vnl_double_4.h>
32 #include <vgl/vgl_fwd.h>
33 
34 class FMatrix;
35 class HomgPoint2D;
36 
37 class FManifoldProject
38 {
39   vnl_double_3x3 F_;
40 
41   // Information to be used for each point
42   vnl_double_4x4 A_;
43   vnl_double_4 t_;
44   vnl_double_4x4 V_;
45   vnl_double_4 d_;
46 
47   bool affine_F_;
48 
49  public:
50   FManifoldProject();
51   FManifoldProject(const FMatrix& F);
52 
53   void set_F(const FMatrix& F);
54   double correct(vgl_homg_point_2d<double> const& point1,
55                  vgl_homg_point_2d<double> const& point2,
56                  vgl_homg_point_2d<double>& out1,
57                  vgl_homg_point_2d<double>& out2) const;
58   double correct(const HomgPoint2D& point1, const HomgPoint2D& point2, HomgPoint2D *, HomgPoint2D *) const;
59   double correct(double   x1, double   y1, double   x2, double   y2,
60                  double *ox1, double *oy1, double *ox2, double *oy2) const;
61 
get_F()62   vnl_double_3x3 const& get_F() const { return F_; }
63 };
64 
65 #endif // FManifoldProject_h_
66