aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/gra/FeaturePoint.h
blob: 4b80a3dc0fe7f4d42201d43da76a8e872685aa21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#ifndef   gra_FeaturePoint_H__
#define   gra_FeaturePoint_H__

#include "../oo/ObjBase.h"

#include "../math/Vector.h"

#include <string>
#include <typeinfo>
#include <cstdlib>
#include <cstdio>

namespace meow {

/*!
 * @brief 特徵點
 *
 * @author cat_leopard
 */
template<class Scalar, class Description>
class FeaturePoint: public ObjBase {
private:
  Vector<Scalar>      pos_;
  Vector<Description> des_;
public:
  /*!
   * @brief constructor
   */
  FeaturePoint() {
  }

  /*!
   * @brief constructor
   */
  FeaturePoint(size_t pDim, size_t dDim):
  pos_(pDim, Scalar(0)), des_(dDim, Description(0)) {
  }

  /*!
   * @brief constructor
   */
  FeaturePoint(FeaturePoint const& fp):
  pos_(fp.pos_), des_(fp.des_) {
  }

  /*!
   * @brief destructor
   */
  ~FeaturePoint() {
  }

  /*!
   * @brief 複製
   */
  FeaturePoint& copyFrom(FeaturePoint const& fp) {
    pos_.copyFrom(fp.pos_);
    des_.copyFrom(fp.des_);
    return *this;
  }

  /*!
   * @brief 參照
   */
  FeaturePoint& referenceFrom(FeaturePoint const& fp) {
    pos_.referenceFrom(fp.pos_);
    des_.referenceFrom(fp.des_);
    return *this;
  }

  /*!
   * @brief 回傳position
   */
  Vector<Scalar> const& position() const {
    return pos_;
  }

  /*!
   * @brief 回傳description
   */
  Vector<Description> const& description() const {
    return des_;
  }

  /*!
   * @brief 修改position
   */
  Vector<Scalar> const& position(Vector<Scalar> const& p) const {
    pos_.copyFrom(p);
    return position();
  }

  /*!
   * @brief 修改description
   */
  Vector<Description> const& description(Vector<Description> const& d) {
    des_.copyFrom(d);
    return description();
  }

  /*!
   * @brief 回傳position的第i個scalar
   */
  Scalar position(size_t index) const {
    return pos_(index);
  }

  /*!
   * @brief 回傳description的第i個Description
   */
  Description description(size_t i) const {
    return des_(i);
  }

  /*!
   * @brief 修改position的第i個scalar
   */
  Scalar position(size_t i, Scalar const& s) {
    pos_.entry(i, s);
    return position(i);
  }

  /*!
   * @brief 修改description的第i個Description
   */
  Description description(size_t i, Description const& d) {
    des_.entry(i, d);
    return description(i);
  }

  /*!
   * @brief 取得position
   */
  Vector<Scalar>& positionGet() {
    return pos_;
  }

  /*!
   * @brief 取得description
   */
  Vector<Description>& descriptionGet() {
    return des_;
  }

  /*!
   * @brief same as copyFrom(fp)
   */
  FeaturePoint& operator=(FeaturePoint const& fp) {
    return copyFrom(fp);
  }

  /*!
   * @brief same as position(i)
   */
  Scalar const& operator()(size_t i) const {
    return position(i);
  }

  /*!
   * @brief same as description(i)
   */
  Description operator[](size_t i) const {
    return description(i);
  }

  bool write(FILE* f, bool bin, unsigned int fg) const {
    return false;
  }

  bool read (FILE* f, bool bin, unsigned int fg) {
    return false;
  }

  ObjBase* create() const {
    return new FeaturePoint();
  }

  ObjBase* copyFrom(ObjBase const& b) {
    return &(copyFrom(*(FeaturePoint*)b));
  }

  char const* ctype() const {
    static char const* ptr = typeid(*this).name();
    return ptr;
  }

  std::string type() const {
    return std::string(ctype());
  }
};

}

#endif // gra_FeaturePoint_H__