aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp.test/src/features_Harris.cpp
blob: f3c2c10d35678b6faee8b97ce5c1852c8782cfa8 (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
#include "features__.h"

#include "meowpp/oo/ObjBase.h"
#include "meowpp/oo/ObjSelector.h"
#include "meowpp/geo/Vectors.h"
#include "meowpp/gra/FeaturePointsDetector_Harris.h"

using namespace meow;

class Harris: public FeaturePointsDetectors {
  private:
    FeaturePointsDetector_Harris<RGBf_Space> detector_;
  public:
    std::string description() const {
      return "Harris-Corner-Detect";
    }
    
    Usage usage() const {
      Usage ret;
      ret.optionAdd("harris-k",
                    "Specify the constant K of 'R = detM - KtraceM'",
                    "<floating point>",
                    stringPrintf("%.10f", detector_.paramK()),
                    false);
      ret.optionAdd("harris-r",
                    "Specify the threshold of R to determind whether is "
                    "featuer point or not",
                    "<floating point>",
                    stringPrintf("%.10f", detector_.paramR()),
                    false);
      ret.optionAdd("harris-w",
                    "Specify the sigma of the gaussian blur",
                    "<floating point>",
                    stringPrintf("%.10f", detector_.paramW()),
                    false);
      ret.optionAdd("harris-n",
                    "Specify the sigma of the gaussian blur to de-noise",
                    "<floating point>",
                    stringPrintf("%.10f", detector_.paramN()),
                    false);
      ret.optionAdd("harris-g",
                    "Specify sigma of the gaussian blur to generate feature",
                    "<floating point>",
                    stringPrintf("%.10f", detector_.paramG()),
                    false);
      ret.optionAdd("harris-l",
                    ".........",
                    "<floating point>",
                    stringPrintf("%.10f", detector_.paramL()),
                    false);
      ret.optionAdd("harris-b",
                    "Description size",
                    "<number>",
                    stringPrintf("%lu", detector_.paramB()),
                    false);
      return ret;
    }
    
    bool usage(meow::Usage const& usg) {
      double K = atof(usg.optionValue("harris-k", 0).c_str());
      double R = atof(usg.optionValue("harris-r", 0).c_str());
      double W = atof(usg.optionValue("harris-w", 0).c_str());
      double N = atof(usg.optionValue("harris-n", 0).c_str());
      double L = atof(usg.optionValue("harris-l", 0).c_str());
      double G = atof(usg.optionValue("harris-g", 0).c_str());
      size_t B = atoi(usg.optionValue("harris-b", 0).c_str());
      detector_.paramK(K);
      detector_.paramR(R);
      detector_.paramW(W);
      detector_.paramN(N);
      detector_.paramL(L);
      detector_.paramG(G);
      detector_.paramB(B);
      return true;
    }
    
    FeaturePoints detect(Bitmap<RGBf_Space> const& bmp) {
      return detector_.detect(bmp);
    }

    std::string type() const { return std::string("Harris"); }
    ObjBase* create() const { return new Harris(); }
};

static meow::ObjSelector<kFPSD_ID> __(new Harris(), true);