Skip to content

Commit 7c4f4ad

Browse files
committed
[feat] WIP. pdb test
1 parent 22139f7 commit 7c4f4ad

File tree

4 files changed

+142
-62
lines changed

4 files changed

+142
-62
lines changed

CMakeLists.txt

+23-34
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_OUTPUT_DIR}/lib) ## mkdir lib
1010
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_OUTPUT_DIR}/lib)
1111

1212
# Build PDB file
13+
# https://stackoverflow.com/questions/28178978/how-to-generate-pdb-files-for-release-build-with-cmake-flags
1314
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
1415
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
16+
#install(FILES $<TARGET_PDB_FILE:${PROJECT_NAME}> DESTINATION bin OPTIONAL)
1517

1618
#set(Boost_LIBRARY_DIRS /usr/local/lib)
1719
#message("Opencv Found --opencv_version " ${OpenCV_VERSION})
@@ -42,57 +44,44 @@ link_directories (${OpenCV_LIBS})
4244
message("OpenCV_INCLUDE_DIRS : " ${OpenCV_INCLUDE_DIRS})
4345
message("OpenCV_LIBS : " ${OpenCV_LIBS})
4446
## BOOST
45-
set(BOOST_ROOT $ENV{THIRD_PARTY}/Boost/boost_1_66_0)
46-
set(BOOST_LIBS ${BOOST_ROOT}/lib)
47-
set(BOOST_INCLUDE_DIRS ${BOOST_ROOT}/include)
48-
include_directories( ${BOOST_INCLUDE_DIRS} )
49-
link_directories (${BOOST_LIBS})
50-
message("BOOST_INCLUDE_DIRS : " ${BOOST_INCLUDE_DIRS})
51-
message("BOOST_LIBS : " ${BOOST_LIBS})
47+
#set(BOOST_ROOT $ENV{THIRD_PARTY}/Boost/boost_1_66_0)
48+
#set(BOOST_LIBS ${BOOST_ROOT}/lib)
49+
#set(BOOST_INCLUDE_DIRS ${BOOST_ROOT}/include)
50+
#include_directories( ${BOOST_INCLUDE_DIRS} )
51+
#link_directories (${BOOST_LIBS})
52+
#message("BOOST_INCLUDE_DIRS : " ${BOOST_INCLUDE_DIRS})
53+
#message("BOOST_LIBS : " ${BOOST_LIBS})
5254
#---------Linux---------
5355
ELSE()
5456
## OpenCV
5557
find_package(OpenCV 3.4.9 REQUIRED)
5658
include_directories(${OpenCV_INCLUDE_DIRS})
5759
link_directories(${OpenCV_LIBRARY_DIRS})
5860
## BOOST
59-
find_package(Boost 1.55.0 COMPONENTS thread)
60-
include_directories(${Boost_INCLUDE_DIRS})
61-
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
62-
## Eigen
63-
#FIND_PACKAGE(Eigen3 REQUIRED)
64-
#include_directories(${EIGEN_INCLUDE_DIRS})
65-
#set(EIGEN_DIRECTORIES /home/ubuntu/workspace/eigen)
66-
#include_directories(${VLFEAT_DIRECTORIES})
67-
#message("vlfeat_include_path : " ${VLFEAT_DIRECTORIES})
68-
## vlfeat
69-
#set(VLFEAT_DIRECTORIES /home/ubuntu/workspace/vlfeat-0.9.20)
70-
#include_directories(${VLFEAT_DIRECTORIES})
71-
#message("vlfeat_include_path : " ${VLFEAT_DIRECTORIES})
72-
#FIND_LIBRARY(VLFEAT_LIBRARY
73-
#NAMES libvl.so
74-
#PATHS /home/ubuntu/workspace/vlfeat-0.9.20/bin/glnxa64
75-
#)
76-
ENDIF()
77-
61+
#find_package(Boost 1.55.0 COMPONENTS thread)
62+
#include_directories(${Boost_INCLUDE_DIRS})
63+
#LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
7864

79-
## file to build
65+
ENDIF()
8066

81-
8267
# code
8368
include_directories(${CMAKE_SOURCE_DIR}/include)
8469
include_directories(${CMAKE_SOURCE_DIR}/include/component)
85-
aux_source_directory(./src SRC)
86-
aux_source_directory(./src/component SRC_COMPONENT) # cpp
70+
aux_source_directory(./src SRC)
71+
aux_source_directory(./src/component SRC_COMPONENT)
8772

8873
# output binary
89-
add_executable(${PROJECT_NAME} main.cpp ${SRC} ${SRC_COMPONENT})
74+
#add_executable(${PROJECT_NAME} main.cpp ${SRC} ${SRC_COMPONENT})
9075
# output so
91-
#add_library( ${PROJECT_NAME} SHARED ${SRC} ${SRC_COMPONENT})
76+
add_library( ${PROJECT_NAME} SHARED ${SRC} ${SRC_COMPONENT})
77+
#add_library( ${PROJECT_NAME} STATIC ${SRC} ${SRC_COMPONENT})
9278
# link library
9379

9480
IF (WIN32)
95-
target_link_libraries(${PROJECT_NAME} opencv_world349.lib boost_system-vc141-mt-x64-1_66.lib libboost_filesystem-vc141-mt-x64-1_66.lib libboost_regex-vc141-mt-x64-1_66.lib)
81+
target_link_libraries(${PROJECT_NAME} opencv_world349.lib)
82+
# boost_system-vc141-mt-x64-1_66.lib libboost_filesystem-vc141-mt-x64-1_66.lib libboost_regex-vc141-mt-x64-1_66.lib
9683
ELSE()
97-
target_link_libraries(${PROJECT_NAME} -lstdc++fs -lboost_system -lboost_filesystem -lboost_regex ${OpenCV_LIBS} ${Boost_LIBRARIES}) #libSpinnaker.so ${Boost_LIBRARIES} ${VLFEAT_LIBRARY} -lgomp
84+
target_link_libraries(${PROJECT_NAME} -lstdc++fs ${OpenCV_LIBS})
85+
# -lgomp -lboost_system -lboost_filesystem -lboost_regex ${Boost_LIBRARIES}
9886
ENDIF()
87+

README.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
# image-processing-opencv
2-
OpneCV 3.4.9
2+
Some algorithms to do image processing.
3+
4+
## Environment
5+
### Compiler:
6+
|Win 10|Ubuntu 1804|
7+
|:--:|:--:|
8+
|Visual studio 2017|GCC 7.5.0|
9+
10+
### Third Party
11+
|Package|Version|
12+
|:--:|:--:|
13+
|OpenCV| 3.4.9|
14+
15+
# How to use (ubuntu)
16+
**include header :** component/image_proc.h
17+
**include so :**

include/common.h

+27-27
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,40 @@
2020
#include "opencv2/xfeatures2d.hpp"
2121

2222
// boost
23-
#include "boost/filesystem.hpp"
24-
#include "boost/regex.hpp"
23+
// #include "boost/filesystem.hpp"
24+
// #include "boost/regex.hpp"
2525

2626
// because c++ 11 don't have make_unique, so we make one by myself.
2727
template <typename T, typename... Args>
2828
static std::unique_ptr<T> make_unique(Args &&...args) {
2929
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
3030
}
3131

32-
inline int LoadFolderPath(const std::string &folder_path, std::vector<std::string> &img_path_vector, std::vector<std::string> &img_filename_vector) {
33-
std::cout << "LoadFolderPath() start" << std::endl;
34-
if (!folder_path.empty()) {
35-
if (!boost::filesystem::exists(folder_path)) {
36-
std::cout << "Folder : " << folder_path << " does not exist." << std::endl;
37-
return -1;
38-
}
39-
// boost::regex pattern(folder_path + "/[0-9]*.png");
40-
boost::filesystem::directory_iterator end_itr;
41-
for (boost::filesystem::directory_iterator itr(folder_path); itr != end_itr; ++itr) {
42-
if (boost::filesystem::is_directory(itr->status())) {
43-
} else if ((itr->path().extension() == ".png") || (itr->path().extension() == ".bmp")) {
44-
std::string imgpath = itr->path().string();
45-
// std::cout << "imgpath : " << imgpath << std::endl;
46-
img_path_vector.push_back(itr->path().string());
47-
img_filename_vector.push_back(itr->path().filename().stem().string());
48-
}
49-
// else if (boost::regex_match(itr->path().string(), pattern)){
50-
// img_path_vector.push_back(itr->path().string());
51-
// }
52-
}
53-
}
54-
std::cout << "LoadFolderPath() end" << std::endl;
55-
return 0;
56-
}
32+
// inline int LoadFolderPath(const std::string &folder_path, std::vector<std::string> &img_path_vector, std::vector<std::string> &img_filename_vector) {
33+
// std::cout << "LoadFolderPath() start" << std::endl;
34+
// if (!folder_path.empty()) {
35+
// if (!boost::filesystem::exists(folder_path)) {
36+
// std::cout << "Folder : " << folder_path << " does not exist." << std::endl;
37+
// return -1;
38+
// }
39+
// // boost::regex pattern(folder_path + "/[0-9]*.png");
40+
// boost::filesystem::directory_iterator end_itr;
41+
// for (boost::filesystem::directory_iterator itr(folder_path); itr != end_itr; ++itr) {
42+
// if (boost::filesystem::is_directory(itr->status())) {
43+
// } else if ((itr->path().extension() == ".png") || (itr->path().extension() == ".bmp")) {
44+
// std::string imgpath = itr->path().string();
45+
// // std::cout << "imgpath : " << imgpath << std::endl;
46+
// img_path_vector.push_back(itr->path().string());
47+
// img_filename_vector.push_back(itr->path().filename().stem().string());
48+
// }
49+
// // else if (boost::regex_match(itr->path().string(), pattern)){
50+
// // img_path_vector.push_back(itr->path().string());
51+
// // }
52+
// }
53+
// }
54+
// std::cout << "LoadFolderPath() end" << std::endl;
55+
// return 0;
56+
// }
5757

5858
inline int ConvertMatToGrayscale(const cv::Mat &src, cv::Mat &gray_dst) {
5959
const int &&channel = src.channels();

include/component/image_proc.h

+76
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,82 @@
66
#include "opencv2/highgui.hpp"
77
#include "opencv2/imgcodecs.hpp"
88

9+
#ifdef computervision_EXPORTS
10+
#define IPO_API __declspec(dllexport)
11+
#else
12+
#define IPO_API __declspec(dllimport)
13+
#endif
14+
915
namespace ipo {
16+
#ifdef _WIN32
17+
/**
18+
* @brief Calculate the diff value between subtraction of grayscale image and fuzzy image. If the value exceed the offset value, then it equal to 255, and vice versa.
19+
* @param src input image.
20+
* @param dst output image.
21+
* @param blur_ksize blurring kernel size.
22+
* @param offset diff value.
23+
* @param mode dynamic threshold mode.
24+
**/
25+
IPO_API int DynamicThreshold(const cv::Mat &src, cv::Mat &dst,
26+
const int &blur_ksize, const int &offset,
27+
const DynamicThresholdTypes &mode);
28+
29+
/**
30+
* @brief Refer to the B&C function of imageJ to stretch the pixel value
31+
* between low_value and high_value. If it exceeds high_value, it is 255, and it
32+
* is 0 if it is less than low_value.
33+
* @param src input image.
34+
* @param dst output image.
35+
* @param low_value Low threshold.
36+
* @param high_value High threshold.
37+
**/
38+
IPO_API int Stretching(const cv::Mat &src, cv::Mat &dst,
39+
const int &low_value, const int &high_value);
40+
41+
/**
42+
*
43+
**/
44+
IPO_API int Variance(const cv::Mat &src, cv::Mat &dst, const int &kernel_size);
45+
IPO_API int FindTheSpecifiedColorByRGB(const cv::Mat &src, cv::Mat &dst,
46+
const int &r, const int &g, const int &b, const double &tolerance);
47+
IPO_API cv::Point TwoLineIntersection(const cv::Point &x1_start, const cv::Point &x1_end,
48+
const cv::Point &x2_start, const cv::Point &x2_end);
49+
IPO_API double GetTwoPointAngle(const cv::Point &pt0, const cv::Point &pt1);
50+
IPO_API int GetNewRotatedImageSize(const cv::Mat &src, const double &angle, int &width, int &height);
51+
IPO_API cv::Mat ImageRotateByCenterAndAdjustBoundary(const cv::Mat &src, const double &angle);
52+
IPO_API cv::Mat ImageRotate(const cv::Mat &src, const double &angle, const cv::Point &center);
53+
IPO_API cv::Mat ImageShift(const cv::Mat &src, const cv::Point2f &from_pt, const cv::Point2f &to_pt);
54+
55+
//====Positioning (PIMPL)====
56+
class Positioning {
57+
public:
58+
IPO_API Positioning(const PositioningTypeEnums &type);
59+
IPO_API ~Positioning();
60+
IPO_API int SetGoldenSampleImage(const cv::Mat &golden_sample_img);
61+
IPO_API int SetRect(const PositioningRectEnums &rect_type, const cv::Rect &rect);
62+
IPO_API int SetAttribute(const int &attribute_type, const double &value);
63+
IPO_API cv::Mat GetResult(const cv::Mat &sample_img);
64+
65+
private:
66+
class PimplPositioning;
67+
std::auto_ptr<PimplPositioning> p_pimplPositioning;
68+
};
69+
70+
//====Flat-field correction====
71+
class FlatFieldCorrection {
72+
public:
73+
IPO_API FlatFieldCorrection();
74+
IPO_API ~FlatFieldCorrection();
75+
IPO_API int SetDarkAndBrightFieldImage(const cv::Mat &dark_field_img,
76+
const cv::Mat &bright_field_img,
77+
const int &mean_pixel_value);
78+
IPO_API cv::Mat GetResult(const cv::Mat &src);
79+
80+
private:
81+
class PimplFlatFieldCorrection;
82+
std::auto_ptr<PimplFlatFieldCorrection> p_pimplFlatFieldCorrection;
83+
};
84+
#else // Linux
1085
/**
1186
* @brief Calculate the diff value between subtraction of grayscale image and fuzzy image. If the value exceed the offset value, then it equal to 255, and vice versa.
1287
* @param src input image.
@@ -74,6 +149,7 @@ class FlatFieldCorrection {
74149
class PimplFlatFieldCorrection;
75150
std::auto_ptr<PimplFlatFieldCorrection> p_pimplFlatFieldCorrection;
76151
};
152+
#endif
77153

78154
} // namespace ipo
79155
#endif // _IMAGE_PROC_H_

0 commit comments

Comments
 (0)