From fe926756145c5e5cf5f315af0acdbfd85ba27543 Mon Sep 17 00:00:00 2001 From: cathook Date: Thu, 19 Jun 2014 07:25:48 +0800 Subject: x --- meowpp/gra/FeaturePointsDetector_Harris.h | 59 +++++++++++++++---------------- 1 file changed, 28 insertions(+), 31 deletions(-) (limited to 'meowpp/gra/FeaturePointsDetector_Harris.h') 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 - 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 MyFeaturePoint; typedef std::vector 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::COPY_FROM) { } //! @brief 解構子 @@ -178,9 +168,11 @@ public: MyFeaturePoints detect(Bitmap const& bmp) const { Bitmap input = bmp; + // gradiance Bitmap input_gx(input.gradianceX(0, self->noiseN_)); Bitmap input_gy(input.gradianceY(self->noiseN_, 0)); + // get Matrix I for each pixel Bitmap Ixx(input.height(), input.width(), 0.0); Bitmap Iyy(input.height(), input.width(), 0.0); Bitmap 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 R(input.height(), input.width(), 0.0); Bitmap 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 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 desc; + std::vector desc; // description for (ssize_t d = 1; d <= (ssize_t)self->boundB_; d++) { std::vector light; size_t max_id = 0; -- cgit v1.2.3