aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/gra/FeaturePoint.h
diff options
context:
space:
mode:
Diffstat (limited to 'meowpp/gra/FeaturePoint.h')
-rw-r--r--meowpp/gra/FeaturePoint.h193
1 files changed, 193 insertions, 0 deletions
diff --git a/meowpp/gra/FeaturePoint.h b/meowpp/gra/FeaturePoint.h
new file mode 100644
index 0000000..4b80a3d
--- /dev/null
+++ b/meowpp/gra/FeaturePoint.h
@@ -0,0 +1,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__