Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KeyPoint.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2007-2008 Anael Orlinski
3 *
4 * This file is part of Panomatic.
5 *
6 * Panomatic is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * Panomatic is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Panomatic; if not, write to the Free Software
18 * <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef __lfeat_keypoint_h
22 #define __lfeat_keypoint_h
23 
24 #include <hugin_shared.h>
25 #include <memory>
26 #include <vector>
27 
28 namespace lfeat
29 {
30 
31 
32 class KeyPoint
33 {
34 public:
35  KeyPoint();
36  KeyPoint(const KeyPoint& k);
37  KeyPoint(double x, double y, double s, double score, int trace);
38  KeyPoint& operator=(const KeyPoint& k) throw();
39 
40  ~KeyPoint();
41 
42  void allocVector(int iSize);
43 
44  double _x, _y;
45  double _scale;
46  double _score;
47  int _trace;
48  double _ori;
49 
50  double* _vec;
51 
52 };
53 
54 inline KeyPoint::KeyPoint() : _x(0), _y(0), _scale(1), _score(0), _trace(0), _ori(0), _vec(0)
55 {
56 
57 }
58 
59 inline KeyPoint::KeyPoint(double x, double y, double s, double score, int trace) :
60  _x(x), _y(y), _scale(s), _score(score), _trace(trace), _ori(0), _vec(0)
61 {
62 
63 }
64 
65 inline KeyPoint::KeyPoint(const KeyPoint& k) :
66  _x(k._x), _y(k._y), _scale(k._scale), _score(k._score), _trace(k._trace), _ori(0), _vec(0)
67 {
68 
69 }
70 
71 
72 inline KeyPoint& KeyPoint::operator=(const KeyPoint& k) throw()
73 {
74  if (this == &k)
75  {
76  return *this;
77  }
78  _x = k._x;
79  _y = k._y;
80  _scale = k._scale;
81  _score = k._score;
82  _trace = k._trace;
83  _vec = 0;
84  _ori = k._ori;
85  return *this;
86 }
87 
89 {
90  if (_vec)
91  {
92  delete[] _vec;
93  }
94 }
95 
96 inline void KeyPoint::allocVector(int iSize)
97 {
98  _vec = new double[iSize];
99 }
100 
101 
102 inline bool operator < (const KeyPoint& iA, const KeyPoint& iB)
103 {
104  return (iA._score < iB._score);
105 }
106 
107 
108 
109 
110 typedef std::shared_ptr<KeyPoint> KeyPointPtr;
111 typedef std::vector<KeyPointPtr> KeyPointVect_t;
112 typedef std::vector<KeyPointPtr>::iterator KeyPointVectIt_t;
113 
115 {
116 public:
117  inline bool operator() (const KeyPointPtr& a, const KeyPointPtr& b) const
118  {
119  if (a->_score < b->_score)
120  {
121  return true;
122  }
123  else if (a->_score > b->_score)
124  {
125  return false;
126  }
127  else
128  {
129  // same score, order by scale
130  return (a->_scale < b->_scale);
131  }
132  }
133 };
134 
135 }
136 
137 #endif //__lfeat_keypoint_h
138 
bool operator<(const KeyPoint &iA, const KeyPoint &iB)
Definition: KeyPoint.h:102
double _scale
Definition: KeyPoint.h:45
std::vector< KeyPointPtr > KeyPointVect_t
Definition: KeyPoint.h:111
KeyPoint & operator=(const KeyPoint &k)
Definition: KeyPoint.h:72
double _score
Definition: KeyPoint.h:46
double _ori
Definition: KeyPoint.h:48
void allocVector(int iSize)
Definition: KeyPoint.h:96
std::shared_ptr< KeyPoint > KeyPointPtr
Definition: KeyPoint.h:110
std::vector< KeyPointPtr >::iterator KeyPointVectIt_t
Definition: KeyPoint.h:112
bool operator()(const KeyPointPtr &a, const KeyPointPtr &b) const
Definition: KeyPoint.h:117
double * _vec
Definition: KeyPoint.h:50