|
1 | 1 | #ifndef _POSITIONING_H_
|
2 | 2 | #define _POSITIONING_H_
|
3 | 3 |
|
| 4 | +#include "attribute.h" |
4 | 5 | #include "common.h"
|
5 | 6 | #include "image_proc.h"
|
6 | 7 | namespace ipo {
|
7 |
| -enum PositioningTypeEnums { |
8 |
| - FEATURE_MATCHING = 0, |
9 |
| - TEMPLATE_MATCHING = 1, |
10 |
| -}; |
11 |
| -enum PositioningRectEnums { |
12 |
| - TEMPLATE_IMG_RECT = 0, |
13 |
| - SEARCHING_IMG_RECT = 1, |
14 |
| -}; |
15 |
| -enum FeatureAttributeEnums { |
16 |
| - HESSIAN_THRESHOLD = 0, // 100~3000 |
17 |
| - LOWE_RATIO = 1, // 0~1.0 |
18 |
| -}; |
19 |
| -enum TemplateAttributeEnums { |
20 |
| - ANGLE_TOLERANCE = 0, // 0~180 |
21 |
| - NUMBER_OF_LEVELS = 1, // 1~5 |
22 |
| - THRESHOLD_SCORE = 2, // 0~1.0 |
23 |
| -}; |
24 |
| - |
25 | 8 | class IPositioning {
|
26 | 9 | public:
|
27 | 10 | virtual int SetGoldenSampleImage(const cv::Mat &golden_sample_img) = 0;
|
@@ -81,53 +64,19 @@ class TemplateMatching : public IPositioning {
|
81 | 64 | class Creator {
|
82 | 65 | public:
|
83 | 66 | // virtual void Create(const PositioningTypeEnums &type) = 0;
|
| 67 | + protected: |
| 68 | + IPositioning *ptr; |
84 | 69 | };
|
85 | 70 |
|
86 |
| -class Positioning : public Creator { |
| 71 | +class Positioning::PimplPositioning : public Creator { |
87 | 72 | public:
|
88 |
| - Positioning(const PositioningTypeEnums &type) { |
89 |
| - switch (type) { |
90 |
| - case PositioningTypeEnums::FEATURE_MATCHING: { |
91 |
| - ptr = new FeatureMatching(); |
92 |
| - break; |
93 |
| - } |
94 |
| - case PositioningTypeEnums::TEMPLATE_MATCHING: { |
95 |
| - ptr = new TemplateMatching(); |
96 |
| - break; |
97 |
| - } |
98 |
| - default: { |
99 |
| - std::cout << "(enum)PositioningTypeEnums There is no such enum in the enumeration list." << std::endl; |
100 |
| - std::cout << "Switch to the default algorithm : TemplateMatching" << std::endl; |
101 |
| - break; |
102 |
| - } |
103 |
| - } |
104 |
| - } |
105 |
| - ~Positioning() { |
106 |
| - delete ptr; |
107 |
| - } |
108 |
| - int SetGoldenSampleImage(const cv::Mat &golden_sample_img) { |
109 |
| - if (ptr->SetGoldenSampleImage(golden_sample_img) != 0) { |
110 |
| - return -1; |
111 |
| - } |
112 |
| - return 0; |
113 |
| - } |
114 |
| - int SetRect(const PositioningRectEnums &rect_type, const cv::Rect &rect) { |
115 |
| - if (ptr->SetRect(rect_type, rect) != 0) { |
116 |
| - return -1; |
117 |
| - } |
118 |
| - return 0; |
119 |
| - } |
120 |
| - int SetAttribute(const int &attribute_type, const double &value) { |
121 |
| - if (ptr->SetAttribute(attribute_type, value) != 0) |
122 |
| - return -1; |
123 |
| - return 0; |
124 |
| - } |
125 |
| - cv::Mat GetResult(const cv::Mat &sample_img) { |
126 |
| - return ptr->GetResult(sample_img); |
127 |
| - } |
128 |
| - |
129 |
| - private: |
130 |
| - IPositioning *ptr; |
| 73 | + // PimplPositioning(); |
| 74 | + PimplPositioning(const PositioningTypeEnums &type); |
| 75 | + ~PimplPositioning(); |
| 76 | + int SetGoldenSampleImage(const cv::Mat &golden_sample_img); |
| 77 | + int SetRect(const PositioningRectEnums &rect_type, const cv::Rect &rect); |
| 78 | + int SetAttribute(const int &attribute_type, const double &value); |
| 79 | + cv::Mat GetResult(const cv::Mat &sample_img); |
131 | 80 | };
|
132 | 81 |
|
133 | 82 | //=========method 2=========
|
|
0 commit comments