diff options
author | cathook <b01902109@csie.ntu.edu.tw> | 2014-06-24 14:23:04 +0800 |
---|---|---|
committer | cathook <b01902109@csie.ntu.edu.tw> | 2014-06-24 14:23:04 +0800 |
commit | 0667012e725099e13045ebf4f2f2bee5bd049edc (patch) | |
tree | 62dd8fb100d493323f24f6e54cf403f2c8ad18c4 /meowpp/gra | |
parent | a9955a1a51df2b268da4d28f9ad10dbaf9815634 (diff) | |
download | meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar.gz meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar.bz2 meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar.lz meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar.xz meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar.zst meow-0667012e725099e13045ebf4f2f2bee5bd049edc.zip |
add test code "feature"
Diffstat (limited to 'meowpp/gra')
-rw-r--r-- | meowpp/gra/BundleAdjustment_LM.h | 24 | ||||
-rw-r--r-- | meowpp/gra/Camera.h | 17 | ||||
-rw-r--r-- | meowpp/gra/Eye.h | 10 | ||||
-rw-r--r-- | meowpp/gra/FeaturePoint.h | 14 | ||||
-rw-r--r-- | meowpp/gra/FeaturePointsDetector_Harris.h | 11 | ||||
-rw-r--r-- | meowpp/gra/IdentityPoints.h | 55 | ||||
-rw-r--r-- | meowpp/gra/Photo.h | 4 | ||||
-rw-r--r-- | meowpp/gra/ViewPort.h | 2 | ||||
-rw-r--r-- | meowpp/gra/WatchBall.h | 30 |
9 files changed, 85 insertions, 82 deletions
diff --git a/meowpp/gra/BundleAdjustment_LM.h b/meowpp/gra/BundleAdjustment_LM.h index 15eaac5..a93a6ef 100644 --- a/meowpp/gra/BundleAdjustment_LM.h +++ b/meowpp/gra/BundleAdjustment_LM.h @@ -44,18 +44,18 @@ private: if (flag == false) { Vector<double> v(4, 0.0); int i = (*pho_).size() - 1, n = 0; - v.entry(n++, (*pho_)[i].focal()); - v.entry(n++, (*rot_)[i].theta(0)); - v.entry(n++, (*rot_)[i].theta(1)); - v.entry(n++, (*rot_)[i].theta(2)); + v.scalar(n++, (*pho_)[i].focal()); + v.scalar(n++, (*rot_)[i].theta(0)); + v.scalar(n++, (*rot_)[i].theta(1)); + v.scalar(n++, (*rot_)[i].theta(2)); return v; } Vector<double> v((*rot_).size() * 4, 0.0); for (size_t n = 0, i = 0, I = (*rot_).size(); i < I; ++i) { - v.entry(n++, (*pho_)[i].focal()); - v.entry(n++, (*rot_)[i].theta(0)); - v.entry(n++, (*rot_)[i].theta(1)); - v.entry(n++, (*rot_)[i].theta(2)); + v.scalar(n++, (*pho_)[i].focal()); + v.scalar(n++, (*rot_)[i].theta(0)); + v.scalar(n++, (*rot_)[i].theta(1)); + v.scalar(n++, (*rot_)[i].theta(2)); } return v; } @@ -90,8 +90,8 @@ private: ) ) ); - ret.entry(n * 2 , tr(0, 0)); - ret.entry(n * 2 + 1, tr(1, 0)); + ret.scalar(n * 2 , tr(0, 0)); + ret.scalar(n * 2 + 1, tr(1, 0)); } //* //for (size_t i = 0; i < ret.dimension(); i++) { @@ -216,8 +216,8 @@ public: std::vector<FPS_K> beg(N), end(N); FPS_K it1, it2; for (size_t i = 0; i < N; ++i) { - beg[i] = (*seq)[i].eye->camera().fixedPoints2D().identityPoints().begin(); - end[i] = (*seq)[i].eye->camera().fixedPoints2D().identityPoints().end (); + beg[i] = (*seq)[i].eye->camera().fixedPoints2D().points().begin(); + end[i] = (*seq)[i].eye->camera().fixedPoints2D().points().end (); } std::vector<std::vector<std::vector<MatchPair> > > all_pairs(N); for (size_t i = 0; i < N; ++i) { diff --git a/meowpp/gra/Camera.h b/meowpp/gra/Camera.h index 174b196..8682ad1 100644 --- a/meowpp/gra/Camera.h +++ b/meowpp/gra/Camera.h @@ -32,9 +32,11 @@ private: Myself() { fixed2D_.dimension(2); } + Myself(Myself const& v): photo_(v.photo_), rot_(v.rot_), fixed2D_(v.fixed2D_) { } + ~Myself() { } }; @@ -78,7 +80,7 @@ public: /*! * @brief 取得 photo */ - Photo<Pixel> const& photo() const { + Photo<Pixel> photo() const { return self->photo_; } @@ -92,7 +94,7 @@ public: /*! * @brief 設定 photo */ - Photo<Pixel> const& photo(Photo<Pixel> const& pho) { + Photo<Pixel> photo(Photo<Pixel> const& pho) { self()->photo_.copyFrom(pho); return photo(); } @@ -100,7 +102,7 @@ public: /*! * @brief 取得rotation */ - Rotation3D<double> const& rotation() const { + Rotation3D<double> rotation() const { return self->rot_; } @@ -114,7 +116,7 @@ public: /*! * @brief 設定rotation */ - Rotation3D<double> const& rotation(Rotation3D<double> const& rot) { + Rotation3D<double> rotation(Rotation3D<double> const& rot) { self()->rot_.copyFrom(rot); return rotation(); } @@ -122,7 +124,7 @@ public: /*! * @brief 取得所有FixedPoint */ - FixedPoints2D const& fixedPoints2D() const { + FixedPoints2D fixedPoints2D() const { return self->fixed2D_; } @@ -136,7 +138,7 @@ public: /*! * @brief 設定FixedPoint */ - FixedPoints2D const& fixedPoints2D(FixedPoints2D const& fps2d) const { + FixedPoints2D fixedPoints2D(FixedPoints2D const& fps2d) const { if (fps2d.dimension() == 2) { self()->fixed2D_.copyFrom(fps2d); } @@ -243,8 +245,7 @@ public: * @return \c char \c const\c * 形式的typename */ char const* ctype() const{ - static char const* ptr = typeid(*this).name(); - return ptr; + return typeid(*this).name(); } /*! @brief 回傳class的type diff --git a/meowpp/gra/Eye.h b/meowpp/gra/Eye.h index 0d62892..cff5ccd 100644 --- a/meowpp/gra/Eye.h +++ b/meowpp/gra/Eye.h @@ -57,7 +57,7 @@ public: return *this; } - Camera<Pixel> const& camera() const { + Camera<Pixel> camera() const { return self->cam_; } @@ -65,12 +65,12 @@ public: return self()->cam_; } - Camera<Pixel> const& camera(Camera<Pixel> const& c) { + Camera<Pixel> camera(Camera<Pixel> const& c) { self()->cam_.copyFrom(c); return camera(); } - Vector3D<double> const& offset() const { + Vector3D<double> offset() const { return self->ofs_; } @@ -78,7 +78,7 @@ public: return self()->ofs_; } - Vector3D<double> const& offset(Vector3D<double> const& ofs) { + Vector3D<double> offset(Vector3D<double> const& ofs) { self()->ofs_ = ofs; return offset(); } @@ -149,7 +149,7 @@ public: * @return this */ ObjBase* copyFrom(ObjBase const* b) { - return &(copyFrom(*(Eye*)b)); + return &(copyFrom(*(Eye const*)b)); } /*! @brief 回傳class的type diff --git a/meowpp/gra/FeaturePoint.h b/meowpp/gra/FeaturePoint.h index c3ab8f3..b2cbd37 100644 --- a/meowpp/gra/FeaturePoint.h +++ b/meowpp/gra/FeaturePoint.h @@ -70,7 +70,7 @@ public: /*! * @brief 回傳position */ - Vector<Scalar> const& position() const { + Vector<Scalar> position() const { return pos_; } @@ -84,7 +84,7 @@ public: /*! * @brief 回傳description */ - Vector<Description> const& description() const { + Vector<Description> description() const { return des_; } @@ -98,7 +98,7 @@ public: /*! * @brief 修改position */ - Vector<Scalar> const& position(Vector<Scalar> const& p) const { + Vector<Scalar> position(Vector<Scalar> const& p) const { pos_.copyFrom(p); return position(); } @@ -106,7 +106,7 @@ public: /*! * @brief 修改description */ - Vector<Description> const& description(Vector<Description> const& d) { + Vector<Description> description(Vector<Description> const& d) { des_.copyFrom(d); return description(); } @@ -129,7 +129,7 @@ public: * @brief 修改position的第i個scalar */ Scalar position(size_t i, Scalar const& s) { - pos_.entry(i, s); + pos_.scalar(i, s); return position(i); } @@ -137,7 +137,7 @@ public: * @brief 修改description的第i個Description */ Description description(size_t i, Description const& d) { - des_.entry(i, d); + des_.scalar(i, d); return description(i); } @@ -217,7 +217,7 @@ public: } ObjBase* copyFrom(ObjBase const& b) { - return &(copyFrom(*(FeaturePoint*)b)); + return &(copyFrom(*(FeaturePoint const*)b)); } char const* ctype() const { diff --git a/meowpp/gra/FeaturePointsDetector_Harris.h b/meowpp/gra/FeaturePointsDetector_Harris.h index e7c6b91..8f0f8fe 100644 --- a/meowpp/gra/FeaturePointsDetector_Harris.h +++ b/meowpp/gra/FeaturePointsDetector_Harris.h @@ -16,7 +16,7 @@ namespace meow { /*! - * @brief Harris corner detect + * @brief Harris-Corner-Detect algorithm for finding feature points. * * @author cat_leopard */ @@ -190,10 +190,12 @@ public: Ixx.gaussianed(self->sizeW_, self->sizeW_); Iyy.gaussianed(self->sizeW_, self->sizeW_); Ixy.gaussianed(self->sizeW_, self->sizeW_); + input_gx.clear(); + input_gy.clear(); // filter too flat or on edge - Bitmap<double> R(input.height(), input.width(), 0.0); - Bitmap<bool> good(input.height(), input.width(), false); + Bitmap<double> R(input.height(), input.width(), 0.0); + Bitmap<bool> good(input.height(), input.width(), false); ssize_t b = self->boundB_; for (ssize_t y = b, Y = -b + input.height(); y < Y; y++) { for (ssize_t x = b, X = -b + input.width(); x < X; x++) { @@ -204,6 +206,9 @@ public: good.pixel(y, x, (r >= self->thresholdR_)); } } + Ixx.clear(); + Iyy.clear(); + Ixy.clear(); // find union neighbor DisjointSet dsj(input.size()); diff --git a/meowpp/gra/IdentityPoints.h b/meowpp/gra/IdentityPoints.h index 1646bf7..edac56e 100644 --- a/meowpp/gra/IdentityPoints.h +++ b/meowpp/gra/IdentityPoints.h @@ -29,11 +29,12 @@ private: IdentityPointsMap points_; size_t dimension_; - Myself() { - dimension_ = 1; + Myself(): dimension_(1) { } + Myself(Myself const& m): points_(m.points_), dimension_(m.dimension_) { } + ~Myself() { } }; @@ -134,77 +135,77 @@ public: /*! * @brief 取得所有identity points */ - IdentityPointsMap const& identityPoints() const { - return self->points_; + IdentityPointsMap const& points() const { + return self()->points_; } /*! * @brief 設定所有identity points */ - IdentityPointsMap const& identityPoints(IdentityPointsMap const& points) { + IdentityPointsMap const& points(IdentityPointsMap const& points) { clear(); - return identityPointsAdd(points); + return pointsAdd(points); } /*! * @brief 加入identity Points */ - IdentityPointsMap const& identityPointsAdd(IdentityPointsMap const& points) { + IdentityPointsMap const& pointsAdd(IdentityPointsMap const& points) { for (IdentityPointsMapIterK it = points.begin(); it != points.end(); ++it) { - identityPointAdd(it.first, it.second); + pointAdd(it.first, it.second); } - return identityPoints(); + return points(); } /*! * @brief 移除identity Points */ - IdentityPointsMap const& identityPointsDel(std::set<ID> const& ids) { + IdentityPointsMap const& pointsDel(std::set<ID> const& ids) { for (typename std::set<ID>::const_iterator it = ids.begin(); it != ids.end(); ++it) { - identityPointDel(*it); + pointDel(*it); } - return identityPoints(); + return points(); } /*! * @brief 取得一個identity point */ - Vector<Scalar> identityPoint(ID const& id) const { + Vector<Scalar> point(ID const& id) const { return (exist(id) ? self->points_.find(id)->second : Vector<Scalar>()); } /*! * @brief 修改一個identity point */ - Vector<Scalar> identityPoint(ID const& id, Vector<Scalar> const& b) { + Vector<Scalar> point(ID const& id, Vector<Scalar> const& b) { if (b.dimension() == self->dimension_ && exist(id)) { self()->points_[id].copyFrom(b); } - return identityPoint(id); + return point(id); } /*! * @brief 新增一個identity point */ - Vector<Scalar> identityPointAdd(ID const& id, Vector<Scalar> const& b) { + Vector<Scalar> pointAdd(ID const& id, Vector<Scalar> const& b) { if (b.dimension() == self->dimension_ && !exist(id)) { self()->points_[id].copyFrom(b); } - return identityPoint(id); + return point(id); } /*! * @brief 刪除一個identity point */ - void identityPointDel(ID const& id) { + void pointDel(ID const& id) { self()->points_.erase(id); } /*! * @brief 取得一個identity point, non-constant reference */ - Vector<Scalar>& identityPointGet(ID const& id) { + Vector<Scalar>& pointGet(ID const& id) { return self()->points_[id]; } @@ -225,8 +226,7 @@ public: if (fwrite(&(dim = dimension()), sizeof(dim), 1, f) < 1) return false; if (fwrite(&(ct = size()), sizeof(ct), 1, f) < 1) return false; for (IdentityPointsMapIterK - it = identityPoints().begin(), ed = identityPoints().end(); - it != ed; ++it) { + it = points().begin(), ed = points().end(); it != ed; ++it) { double tmp; if (fwrite(&(tmp = it->first), sizeof(tmp), 1, f) < 1) return false; for (long i = 0; i < dim; ++i) { @@ -238,8 +238,7 @@ public: else { if (fprintf(f, "%ld %lu\n", dimension(), size()) < 1) return false; for (IdentityPointsMapIterK - it = identityPoints().begin(), ed = identityPoints().end(); - it != ed; ++it) { + it = points().begin(), ed = points().end(); it != ed; ++it) { if (fprintf(f, "%f ", (double)it->first) < 1) return false; for (long i = 0, I = dimension(); i < I; ++i) { if (fprintf(f, "%f ", (double)it->second(i)) < 1) return false; @@ -266,9 +265,9 @@ public: if (fread(&id, sizeof(id), 1, f) < 1) return false; for (size_t j = 0, J = dim; j < J; ++j) { if (fread(&tt, sizeof(tt), 1, f) < 1) return false; - tmp.entry(j, tt); + tmp.scalar(j, tt); } - identityPointAdd((ID)id, tmp); + pointAdd((ID)id, tmp); } } else { @@ -280,9 +279,9 @@ public: if (fscanf(f, "%lf", &id) < 1) return false; for (int j = 0, J = dim; j < J; ++j) { if (fscanf(f, "%lf", &tt) < 1) return false; - tmp.entry(j, tt); + tmp.scalar(j, tt); } - identityPointAdd((ID)id, tmp); + pointAdd((ID)id, tmp); } } return true; @@ -326,6 +325,6 @@ public: } }; -} +} // meow #endif // gra_IdentityPoints_H__ diff --git a/meowpp/gra/Photo.h b/meowpp/gra/Photo.h index 78063ec..1545608 100644 --- a/meowpp/gra/Photo.h +++ b/meowpp/gra/Photo.h @@ -178,7 +178,7 @@ public: /*! * @brief 回傳\c bitmap */ - Bitmap<Pixel> const& bitmap() const { + Bitmap<Pixel> bitmap() const { return self->bmp_; } @@ -195,7 +195,7 @@ public: * @param [in] bmp 新的 bitmap * @return 新的 \c bitmap */ - Bitmap<Pixel> const& bitmap(Bitmap<Pixel> const& bmp) { + Bitmap<Pixel> bitmap(Bitmap<Pixel> const& bmp) { self()->bmp_.copyFrom(bmp); return bitmap(); } diff --git a/meowpp/gra/ViewPort.h b/meowpp/gra/ViewPort.h index 16d8ae1..81ad8f3 100644 --- a/meowpp/gra/ViewPort.h +++ b/meowpp/gra/ViewPort.h @@ -13,7 +13,7 @@ class ViewPort: public ObjBase { }; -} +} // meow #endif // gra_ViewPort_H__ diff --git a/meowpp/gra/WatchBall.h b/meowpp/gra/WatchBall.h index 8bccf7f..8bc99d0 100644 --- a/meowpp/gra/WatchBall.h +++ b/meowpp/gra/WatchBall.h @@ -29,12 +29,11 @@ private: Myself() { } - ~Myself() { + + Myself(Myself const& b): cameras_(b.cameras_), offset_(b.offset_) { } - Myself& copyFrom(Myself const& b) { - cameras_ = b.cameras_; - offset_ = b. offset_; - return *this; + + ~Myself() { } }; @@ -84,7 +83,7 @@ public: /*! * @brief 取得 cameras */ - Cameras const& cameras() const { + Cameras cameras() const { return self->cameras_; } @@ -98,7 +97,7 @@ public: /*! * @brief 設定 camera */ - Cameras const& cameras(Cameras const& c) { + Cameras cameras(Cameras const& c) { self()->cameras_ = c; return cameras(); } @@ -106,21 +105,21 @@ public: /*! * @brief 取得第i個camera */ - Camera<Pixel> const& camera(size_t i) const { + Camera<Pixel> camera(size_t i) const { return cameras()[i]; } /*! * @brief 取得第i個camera (non-constant reference) */ - Camera<Pixel>& camera(size_t i) { + Camera<Pixel>& cameraGet(size_t i) { return cameras()[i]; } /*! * @brief 設定第i個camera */ - Camera<Pixel> const& camera(size_t i, Camera<Pixel> const& c) { + Camera<Pixel> camera(size_t i, Camera<Pixel> const& c) { cameras()[i] = c; return camera(i); } @@ -128,21 +127,21 @@ public: /*! * @brief 取得offset */ - Vector3D<double> const& offset() const { + Vector3D<double> offset() const { return self->offset_; } /*! * @brief 取得offset (non-constant reference) */ - Vector3D<double>& offset() { + Vector3D<double>& offsetGet() { return self()->offset_; } /*! * @brief 設定offset */ - Vector3D<double> const& offset(Vector3D<double> const& ofs) { + Vector3D<double> offset(Vector3D<double> const& ofs) { self()->offset_ = ofs; return offset(); } @@ -228,7 +227,7 @@ public: * @return this */ ObjBase* copyFrom(ObjBase const* b) { - return &(copyFrom(*(WatchBall*)b)); + return &(copyFrom(*(WatchBall const*)b)); } /*! @brief 回傳class的type @@ -236,8 +235,7 @@ public: * @return \c char \c const\c * 形式的typename */ char const* ctype() const{ - static char const* ptr = typeid(*this).name(); - return ptr; + return typeid(*this).name(); } /*! @brief 回傳class的type |