aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/gra/FeaturePointsDetector_Harris.h
diff options
context:
space:
mode:
authorcathook <b01902109@csie.ntu.edu.tw>2014-06-19 07:25:48 +0800
committercathook <b01902109@csie.ntu.edu.tw>2014-06-19 07:25:48 +0800
commitfe926756145c5e5cf5f315af0acdbfd85ba27543 (patch)
tree4d75f94b87fd6d60262f2377d92f5896faf1be7d /meowpp/gra/FeaturePointsDetector_Harris.h
parentb2b55d8c642524274d8115d5b1863e1a40715887 (diff)
downloadmeow-fe926756145c5e5cf5f315af0acdbfd85ba27543.tar
meow-fe926756145c5e5cf5f315af0acdbfd85ba27543.tar.gz
meow-fe926756145c5e5cf5f315af0acdbfd85ba27543.tar.bz2
meow-fe926756145c5e5cf5f315af0acdbfd85ba27543.tar.lz
meow-fe926756145c5e5cf5f315af0acdbfd85ba27543.tar.xz
meow-fe926756145c5e5cf5f315af0acdbfd85ba27543.tar.zst
meow-fe926756145c5e5cf5f315af0acdbfd85ba27543.zip
x
Diffstat (limited to 'meowpp/gra/FeaturePointsDetector_Harris.h')
-rw-r--r--meowpp/gra/FeaturePointsDetector_Harris.h59
1 files changed, 28 insertions, 31 deletions
diff --git a/meowpp/gra/FeaturePointsDetector_Harris.h b/meowpp/gra/FeaturePointsDetector_Harris.h
index 25a46b2..11529f0 100644
--- a/meowpp/gra/FeaturePointsDetector_Harris.h
+++ b/meowpp/gra/FeaturePointsDetector_Harris.h
@@ -13,7 +13,6 @@
#include <vector>
-
namespace meow {
/*!
@@ -33,27 +32,26 @@ private:
double lightL_;
double featureG_;
size_t boundB_;
-
- Myself() {
- ratioK_ = 0.03;
- thresholdR_ = 0.001;
- sizeW_ = 2.0;
- noiseN_ = 3.0;
- lightL_ = 30.0;
- featureG_ = 3.0;
- boundB_ = 10u;
+
+ Myself():
+ ratioK_(0.03),
+ thresholdR_(0.001),
+ sizeW_(2.0),
+ noiseN_(3.0),
+ lightL_(30.0),
+ featureG_(3.0),
+ boundB_(10u) {
}
- ~Myself() {
+ Myself(Myself const& m):
+ ratioK_(m.ratioK_),
+ thresholdR_(m.thresholdR_),
+ sizeW_(m.sizeW_),
+ noiseN_(m.noiseN_),
+ lightL_(m.lightL_),
+ featureG_(m.featureG_),
+ boundB_(m.boundB_){
}
- Myself& copyFrom(Myself const& b) {
- ratioK_ = b.ratioK_ ;
- thresholdR_ = b.thresholdR_ ;
- sizeW_ = b.sizeW_ ;
- noiseN_ = b.noiseN_ ;
- lightL_ = b.lightL_ ;
- featureG_ = b.featureG_ ;
- boundB_ = b.boundB_ ;
- return *this;
+ ~Myself() {
}
};
@@ -62,19 +60,11 @@ public:
typedef FeaturePoint<double, double> MyFeaturePoint;
typedef std::vector<MyFeaturePoint> MyFeaturePoints;
//! @brief constructor 使用預設參數
- FPD_Harris(): self(true) {
- self()->ratioK_ = 0.03;
- self()->thresholdR_ = 0.001;
- self()->sizeW_ = 2.0;
- self()->noiseN_ = 3.0;
- self()->lightL_ = 30.0;
- self()->featureG_ = 3.0;
- self()->boundB_ = 10u;
+ FPD_Harris(): self() {
}
//! @brief constructor 參數複製自另一個 FeaturePointsDetector_Harris
- FPD_Harris(FPD_Harris const& fps): self(false) {
- self().copyFrom(fps.self);
+ FPD_Harris(FPD_Harris const& fps): self(fps.self, Self<Myself>::COPY_FROM) {
}
//! @brief 解構子
@@ -178,9 +168,11 @@ public:
MyFeaturePoints detect(Bitmap<Pixel> const& bmp) const {
Bitmap<Pixel> input = bmp;
+ // gradiance
Bitmap<Pixel> input_gx(input.gradianceX(0, self->noiseN_));
Bitmap<Pixel> input_gy(input.gradianceY(self->noiseN_, 0));
+ // get Matrix I for each pixel
Bitmap<double> Ixx(input.height(), input.width(), 0.0);
Bitmap<double> Iyy(input.height(), input.width(), 0.0);
Bitmap<double> Ixy(input.height(), input.width(), 0.0);
@@ -194,10 +186,12 @@ public:
}
}
+ // blur
Ixx.gaussianed(self->sizeW_, self->sizeW_);
Iyy.gaussianed(self->sizeW_, self->sizeW_);
Ixy.gaussianed(self->sizeW_, self->sizeW_);
+ // filter too flat or on edge
Bitmap<double> R(input.height(), input.width(), 0.0);
Bitmap<bool> good(input.height(), input.width(), false);
ssize_t b = self->boundB_;
@@ -211,6 +205,7 @@ public:
}
}
+ // find union neighbor
DisjointSet dsj(input.size());
ssize_t dy[2] = {0, 1};
ssize_t dx[2] = {1, 0};
@@ -227,6 +222,7 @@ public:
}
}
+ // find local maximum
std::vector<size_t> max_i(input.size());
for (size_t i = 0, I = input.size(); i < I; i++) {
max_i[i] = i;
@@ -239,6 +235,7 @@ public:
}
}
+ // blur before get description
input.gaussianed(self->featureG_, self->featureG_);
MyFeaturePoints ret;
@@ -253,7 +250,7 @@ public:
}
ssize_t dx[4] = {1, 0, -1, 0};
ssize_t dy[4] = {0, 1, 0, -1};
- std::vector<double> desc;
+ std::vector<double> desc; // description
for (ssize_t d = 1; d <= (ssize_t)self->boundB_; d++) {
std::vector<double> light;
size_t max_id = 0;