1 // This is oxl/mvl/HomgInterestPointSet.h
2 #ifndef HomgInterestPointSet_h_
3 #define HomgInterestPointSet_h_
4 //:
5 // \file
6 // \brief Set of interest points on an image
7 //
8 // HomgInterestPointSet holds a set of corners (or points of interest) computed
9 // from an image.  The current implementation provides a moderately
10 // abstract interface, but assumes that it is efficient to associate
11 // an index with each corner.  I \e know this ought to be elsewhere.
12 //
13 // \author
14 //     Andrew W. Fitzgibbon, Oxford RRG, 17 Aug 96
15 //
16 // \verbatim
17 //  Modifications:
18 //   Peter Vanroose - 27 aug.97 - moved std::vector<HomgInterestPoint> instantiation to Templates
19 //   Peter Vanroose - 22 oct.02 - added vgl_homg_point_2d interface
20 // \endverbatim
21 //-----------------------------------------------------------------------------
22 
23 #include <vector>
24 #include <iostream>
25 #include <iosfwd>
26 #ifdef _MSC_VER
27 #  include <vcl_msvc_warnings.h>
28 #endif
29 
30 #include <vnl/vnl_double_2.h>
31 #include <vgl/vgl_homg_point_2d.h>
32 
33 #include <mvl/HomgPoint2D.h>
34 #include <mvl/HomgMetric.h>
35 
36 class vil1_image;
37 class ImageMetric;
38 class HomgInterestPointSetData;
39 class HomgInterestPoint;
40 
41 class HomgInterestPointSet
42 {
43   // Data Members--------------------------------------------------------------
44   HomgInterestPointSetData* data_;
45   HomgMetric conditioner_;
46 
47  public:
48   // Constructors/Destructors--------------------------------------------------
49 
50   HomgInterestPointSet();
51   HomgInterestPointSet(const HomgMetric&);
52   HomgInterestPointSet(const char* filename, const HomgMetric& = nullptr);
53   HomgInterestPointSet(const std::vector<HomgPoint2D>&, ImageMetric* conditioner);
54   HomgInterestPointSet(std::vector<vgl_homg_point_2d<double> > const&, ImageMetric* conditioner);
55   HomgInterestPointSet(const HomgInterestPointSet& that);
56  ~HomgInterestPointSet();
57 
58   HomgInterestPointSet& operator=(const HomgInterestPointSet& that);
59 
60   // Operations----------------------------------------------------------------
61   // void set(const IUPointGroup&, const HomgMetric& c);
62 
63   // Data Access---------------------------------------------------------------
64   unsigned size() const;
65 
66   //: Return i'th interest pt.
67   const HomgPoint2D& operator[](int i) const { return get_homg(i); }
68 
69   HomgInterestPoint& get(int i);
70   HomgInterestPoint const& get(int i) const;
71   vnl_double_2 const& get_2d(int i) const;
72   vnl_vector_fixed<int,2> const& get_int(int i) const;
73   HomgPoint2D const& get_homg(int i) const;
74   vgl_homg_point_2d<double> homg_point(int i) const;
75   float              get_mean_intensity(int i) const;
76 
77   std::vector<HomgPoint2D> const & get_homg_points() const;
78   std::vector<vgl_homg_point_2d<double> > homg_points() const;
79 
get_conditioner()80   const ImageMetric* get_conditioner() const { return (const ImageMetric*)conditioner_; }
81   void set_conditioner(const HomgMetric& c);
82 
83   // Data Control--------------------------------------------------------------
84   bool add(double x, double y); // image coordinates
85   bool add(const HomgPoint2D&);
86   bool add(vgl_homg_point_2d<double> const&);
87   bool add(const HomgInterestPoint&);
88   bool add_preconditioned(const HomgPoint2D&);
89   bool add_preconditioned(vgl_homg_point_2d<double> const&);
90   void set_image(vil1_image const& image);
91   void clear();
92 
93   // Input/Output--------------------------------------------------------------
94   bool read(const char* filename, const HomgMetric& c = nullptr);
95   bool read(const char* filename, vil1_image const& src, const HomgMetric& c = nullptr);
96   bool write(const char* filename) const;
97 
98   bool read(std::istream& f, const ImageMetric* c);
99   bool write(std::ostream& f, const ImageMetric* c) const;
100 
101  protected:
102   void init_conditioner(const HomgMetric& c = nullptr);
103   void delete_conditioner();
104 };
105 
106 #endif // HomgInterestPointSet_h_
107