Skip to content

Commit 6142a55

Browse files
committed
[chore] comment out some unuseful code
1 parent 568af3c commit 6142a55

File tree

6 files changed

+39
-18
lines changed

6 files changed

+39
-18
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ aux_source_directory(./src/component SRC_COMPONENT) # cpp
8888
# output binary
8989
add_executable(${PROJECT_NAME} main.cpp ${SRC} ${SRC_COMPONENT})
9090
# output so
91-
#add_library( ${PROJECT_NAME} SHARED ${SRC} )
91+
#add_library( ${PROJECT_NAME} SHARED ${SRC} ${SRC_COMPONENT})
9292
# link library
9393

9494
IF (WIN32)

include/component/image_proc.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#ifndef _IMAGE_PROC_H_
22
#define _IMAGE_PROC_H_
33

4-
#include "common.h"
4+
// #include "common.h"
5+
// #include "opencv2/highgui.hpp"
6+
// #include "opencv2/imgcodecs.hpp"
7+
#include "opencv2/core.hpp"
8+
// #include "opencv2/imgproc.hpp"
59

610
namespace ipo {
711

@@ -46,15 +50,8 @@ cv::Point TwoLineIntersection(const cv::Point &x1_start, const cv::Point &x1_end
4650
const cv::Point &x2_start, const cv::Point &x2_end);
4751
double GetTwoPointAngle(const cv::Point &pt0, const cv::Point &pt1);
4852
int GetNewRotatedImageSize(const cv::Mat &src, const double &angle, int &width, int &height);
49-
cv::Mat ImageRotateByCenter(const cv::Mat &src, const double &angle);
53+
cv::Mat ImageRotateByCenterAndAdjustBoundary(const cv::Mat &src, const double &angle);
5054
cv::Mat ImageRotate(const cv::Mat &src, const double &angle, const cv::Point &center);
5155
cv::Mat ImageShift(const cv::Mat &src, const cv::Point2f &from_pt, const cv::Point2f &to_pt);
52-
53-
// cv::Mat PositioningByFeatureMatching(const cv::Mat &golden_sample_img,
54-
// const cv::Mat sample_img,
55-
// const cv::Rect &template_rect,
56-
// const cv::Rect &searching_rect,
57-
// const int &hessian_threshold,
58-
// const float &lowe_ratio);
5956
} // namespace ipo
6057
#endif // _IMAGE_PROC_H_

include/component/positioning.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#ifndef _POSITIONING_H_
22
#define _POSITIONING_H_
3-
#include <memory>
43

54
#include "common.h"
65
#include "image_proc.h"
@@ -62,6 +61,7 @@ class TemplateMatching : public IPositioning {
6261
// template <typename T>
6362
int SetAttribute(const int &attribute_type, const double &value);
6463
cv::Mat GetResult(const cv::Mat &sample_img);
64+
int GG(){};
6565

6666
private:
6767
//----cv::Rect----
@@ -77,6 +77,7 @@ class TemplateMatching : public IPositioning {
7777
double similarity_score;
7878
};
7979

80+
//=========method 1=========
8081
class Creator {
8182
public:
8283
// virtual void Create(const PositioningTypeEnums &type) = 0;
@@ -129,6 +130,26 @@ class Positioning : public Creator {
129130
IPositioning *ptr;
130131
};
131132

133+
//=========method 2=========
134+
// class Creator {
135+
// public:
136+
// virtual IPositioning *GetInstance(const PositioningTypeEnums &type) = 0;
137+
// };
138+
// class Positioning : public Creator {
139+
// public:
140+
// IPositioning *GetInstance(const PositioningTypeEnums &type) {
141+
// switch (type) {
142+
// case PositioningTypeEnums::FEATURE_MATCHING: {
143+
// return new FeatureMatching();
144+
// }
145+
// case PositioningTypeEnums::TEMPLATE_MATCHING: {
146+
// return new TemplateMatching();
147+
// }
148+
// }
149+
// }
150+
151+
// };
152+
132153
// class Positioning {
133154
// public:
134155
// static std::shared_ptr<IPositioning> Create(const PositioningTypeEnums &type) {

main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ cv::Mat &&src = cv::imread("../images/Okonomiyaki.png");
1515
------positioning------
1616
8 : positioning by feature matching(SURF)
1717
9 : positioning by template matching
18+
10 :
1819
*/
1920
#define index 9
2021

@@ -86,6 +87,7 @@ int main() {
8687
return 0;
8788
}
8889
#elif index == 7
90+
// GetNewRotatedImageSize()
8991
int main() {
9092
cv::resize(src, src, cv::Size(), 0.6, 0.6);
9193

@@ -99,6 +101,7 @@ int main() {
99101
return 0;
100102
}
101103
#elif index == 8
104+
// positioning by feature matching(SURF)
102105
int main() {
103106
//----Load images----
104107
cv::Mat &&golden_sample = cv::imread("../images/positioning/golden_sample.jpg");
@@ -125,6 +128,7 @@ int main() {
125128
cv::waitKey(0);
126129
}
127130
#elif index == 9
131+
// positioning by template matching
128132
int main() {
129133
//----Load images----
130134
cv::Mat &&golden_sample = cv::imread("../images/positioning/golden_sample.jpg");
@@ -152,4 +156,6 @@ int main() {
152156
cv::imshow("dst", dst);
153157
cv::waitKey(0);
154158
}
159+
#elif index == 10
160+
155161
#endif

src/component/image_proc.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "component/image_proc.h"
22

3+
#include "common.h"
34
#include "component/positioning.h"
45

56
namespace ipo {
@@ -422,10 +423,10 @@ int GetNewRotatedImageSize(const cv::Mat &src,
422423
return 0;
423424
}
424425

425-
cv::Mat ImageRotateByCenter(const cv::Mat &src, const double &angle) {
426+
cv::Mat ImageRotateByCenterAndAdjustBoundary(const cv::Mat &src, const double &angle) {
426427
// check input images
427428
if (src.empty()) {
428-
std::cout << "\nError: ipo::ImageRotateByCenter() --(cv::Mat)src.empty" << std::endl;
429+
std::cout << "\nError: ipo::ImageRotateByCenterAndAdjustBoundary() --(cv::Mat)src.empty" << std::endl;
429430
return {};
430431
}
431432

src/component/positioning.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ cv::Mat TemplateMatching::GetResult(const cv::Mat &sample_img) {
364364
height = gray_searching.rows - gray_template.rows + 1;
365365
result_img = cv::Mat::zeros(width, height, CV_8UC1);
366366
rotated_gray_searching = cv::Mat::zeros(width, height, CV_8UC1);
367-
rotated_gray_searching = ImageRotateByCenter(gray_searching, -current_angle);
367+
rotated_gray_searching = ImageRotateByCenterAndAdjustBoundary(gray_searching, -current_angle);
368368
cv::matchTemplate(rotated_gray_searching, gray_template, result_img, cv::TM_CCOEFF_NORMED);
369369
cv::minMaxLoc(result_img, &minVal, &maxVal, &minLoc, &maxLoc, cv::noArray());
370370
if (maxVal > temp_max) {
@@ -377,7 +377,6 @@ cv::Mat TemplateMatching::GetResult(const cv::Mat &sample_img) {
377377

378378
// rotate image
379379
global_gray_searching = ImageRotate(global_gray_searching, -angle, cv::Point(global_gray_searching.cols / 2, global_gray_searching.rows / 2));
380-
cv::imshow("global_gray_searching", global_gray_searching);
381380
// find global coordinate
382381
width = global_gray_searching.cols - global_gray_template.cols + 1;
383382
height = global_gray_searching.rows - global_gray_template.rows + 1;
@@ -388,10 +387,7 @@ cv::Mat TemplateMatching::GetResult(const cv::Mat &sample_img) {
388387
// result
389388
cv::Mat &&dst = cv::Mat::zeros(sample_img.size(), sample_img.type());
390389
dst = sample_img.clone();
391-
392-
// dst = ImageRotateByCenter(dst, -angle);
393390
dst = ImageRotate(dst, -angle, cv::Point(dst.cols / 2, dst.rows / 2));
394-
395391
dst = ImageShift(dst, maxLoc, cv::Point(template_rect.x, template_rect.y));
396392
return dst.clone();
397393
}

0 commit comments

Comments
 (0)