@@ -15,19 +15,19 @@ enum PositioningRectEnums {
15
15
};
16
16
enum FeatureAttributeEnums {
17
17
HESSIAN_THRESHOLD = 0 , // 100~3000
18
- LOWE_RATIO = 1 , // 0~1.0f
18
+ LOWE_RATIO = 1 , // 0~1.0
19
19
};
20
20
enum TemplateAttributeEnums {
21
- ANGLE_TOLERANCE = 0 ,
22
- NUMBER_OF_LEVELS = 1 ,
23
- THRESHOLD_SCORE = 2 ,
21
+ ANGLE_TOLERANCE = 0 , // 0~180
22
+ NUMBER_OF_LEVELS = 1 , // 1~5
23
+ THRESHOLD_SCORE = 2 , // 0~1.0
24
24
};
25
25
26
26
class IPositioning {
27
27
public:
28
28
virtual int SetGoldenSampleImage (const cv::Mat &golden_sample_img) = 0;
29
29
virtual int SetRect (const PositioningRectEnums &rect_type, const cv::Rect &rect) = 0;
30
- virtual int SetAttribute (const int &attribute_type, const float &value) = 0;
30
+ virtual int SetAttribute (const int &attribute_type, const double &value) = 0;
31
31
virtual cv::Mat GetResult (const cv::Mat &sample_img) = 0;
32
32
};
33
33
@@ -36,38 +36,46 @@ class FeatureMatching : public IPositioning {
36
36
int SetGoldenSampleImage (const cv::Mat &golden_sample_img);
37
37
int SetRect (const PositioningRectEnums &rect_type, const cv::Rect &rect);
38
38
// template <typename T>
39
- int SetAttribute (const int &attribute_type, const float &value);
39
+ int SetAttribute (const int &attribute_type, const double &value);
40
40
cv::Mat GetResult (const cv::Mat &sample_img);
41
41
42
42
private:
43
- cv::Mat golden_sample_image;
43
+ cv::Mat GetHomography (const cv::Mat &sample_img);
44
+
45
+ private:
46
+ // ----cv::Rect----
44
47
cv::Rect template_rect;
45
48
cv::Rect searching_rect;
46
-
47
- int hessian_threshold;
48
- float lowe_ratio;
49
+ // ----cv::Mat----
50
+ cv::Mat golden_sample_image;
49
51
cv::Mat template_img;
50
52
cv::Mat searching_img;
51
- cv::Mat GetHomography (const cv::Mat &sample_img);
53
+ // ----attribute----
54
+ int hessian_threshold;
55
+ float lowe_ratio;
52
56
};
53
57
54
- // class TemplateMatching : public IPositioning {
55
- // public:
56
- // int SetGoldenSampleImage(const cv::Mat &golden_sample_img);
57
- // int SetRect(const PositioningRectEnums &rect_type, const cv::Rect &rect);
58
- // // template <typename T>
59
- // int SetAttribute(const int &attribute_type, const float &value);
60
- // cv::Mat GetResult(const cv::Mat &sample_img);
61
-
62
- // private:
63
- // cv::Mat golden_sample_image;
64
- // cv::Rect template_rect;
65
- // cv::Rect searching_rect;
58
+ class TemplateMatching : public IPositioning {
59
+ public:
60
+ int SetGoldenSampleImage (const cv::Mat &golden_sample_img);
61
+ int SetRect (const PositioningRectEnums &rect_type, const cv::Rect &rect);
62
+ // template <typename T>
63
+ int SetAttribute (const int &attribute_type, const double &value);
64
+ cv::Mat GetResult (const cv::Mat &sample_img);
66
65
67
- // double angle_tolerance;
68
- // int number_of_levels;
69
- // double threshold_score;
70
- // };
66
+ private:
67
+ // ----cv::Rect----
68
+ cv::Rect template_rect;
69
+ cv::Rect searching_rect;
70
+ // ----cv::Mat----
71
+ cv::Mat golden_sample_image;
72
+ cv::Mat template_img;
73
+ cv::Mat searching_img;
74
+ // ----attribute----
75
+ double angle_tolerance;
76
+ int number_of_levels;
77
+ double similarity_score;
78
+ };
71
79
72
80
class Creator {
73
81
public:
@@ -79,12 +87,11 @@ class Positioning : public Creator {
79
87
Positioning (const PositioningTypeEnums &type) {
80
88
switch (type) {
81
89
case PositioningTypeEnums::FEATURE_MATCHING: {
82
- this ->ptr_index = 0 ;
83
90
ptr = new FeatureMatching ();
84
91
break ;
85
92
}
86
93
case PositioningTypeEnums::TEMPLATE_MATCHING: {
87
- this -> ptr_index = 1 ;
94
+ ptr = new TemplateMatching () ;
88
95
break ;
89
96
}
90
97
default : {
@@ -109,7 +116,7 @@ class Positioning : public Creator {
109
116
}
110
117
return 0 ;
111
118
}
112
- int SetAttribute (const int &attribute_type, float value) {
119
+ int SetAttribute (const int &attribute_type, const double & value) {
113
120
if (ptr->SetAttribute (attribute_type, value) != 0 )
114
121
return -1 ;
115
122
return 0 ;
0 commit comments