Skip to content

Commit 039f868

Browse files
committed
Use minimal build of OpenCV library
See: shimat/opencvsharp#1592
1 parent 32dedc3 commit 039f868

File tree

8 files changed

+227
-0
lines changed

8 files changed

+227
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.patch text eol=lf

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ Aardvark.log
3535
**/.vs
3636
.idea
3737
src/Aardvark.sln.DotSettings.user
38+
build_minimal

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@
1010
[![NuGet](https://badgen.net/nuget/dt/Aardvark.OpenCV)](https://www.nuget.org/packages/Aardvark.OpenCV/)
1111

1212
Contains algorithms and utilities using OpenCV via the [OpenCVSharp](https://github.com/shimat/opencvsharp) wrapper for the Aardvark Platform.
13+
14+
## Building
15+
We use a minimal version of OpenCV (and OpenCVSharp) only supporting the `core` and `imgproc` modules. To build this version on Windows run `build_minimal_opencvsharp.ps1`. Other platforms are not supported at the moment.

build_minimal_opencvsharp.patch

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
diff --git a/src/OpenCvSharpExtern/CMakeLists.txt b/src/OpenCvSharpExtern/CMakeLists.txt
2+
index 4371d2f6..4d5ca954 100644
3+
--- a/src/OpenCvSharpExtern/CMakeLists.txt
4+
+++ b/src/OpenCvSharpExtern/CMakeLists.txt
5+
@@ -9,19 +9,20 @@ IF(APPLE)
6+
link_directories(/usr/local/lib)
7+
ENDIF()
8+
9+
-file(GLOB OPENCVSHARP_FILES *.cpp)
10+
+file(GLOB OPENCVSHARP_FILES core*.cpp imgp*.cpp std*.cpp)
11+
+# file(GLOB OPENCVSHARP_FILES *.cpp)
12+
13+
find_package(OpenCV REQUIRED)
14+
15+
# iconv support isn't automatic on some systems
16+
-if(CMAKE_VERSION VERSION_GREATER "3.11")
17+
- find_package(Iconv QUIET)
18+
- if(Iconv_FOUND)
19+
- ocv_target_link_libraries(${the_module} Iconv::Iconv)
20+
- else()
21+
- ocv_target_compile_definitions(${the_module} PRIVATE "NO_ICONV=1")
22+
- endif()
23+
-endif()
24+
+# if(CMAKE_VERSION VERSION_GREATER "3.11")
25+
+# find_package(Iconv QUIET)
26+
+# if(Iconv_FOUND)
27+
+# ocv_target_link_libraries(${the_module} Iconv::Iconv)
28+
+# else()
29+
+# ocv_target_compile_definitions(${the_module} PRIVATE "NO_ICONV=1")
30+
+# endif()
31+
+# endif()
32+
33+
if(OpenCV_FOUND)
34+
include_directories(${OpenCV_INCLUDE_DIRS})
35+
diff --git a/src/OpenCvSharpExtern/include_opencv.h b/src/OpenCvSharpExtern/include_opencv.h
36+
index d65eb67e..a9e4c65b 100644
37+
--- a/src/OpenCvSharpExtern/include_opencv.h
38+
+++ b/src/OpenCvSharpExtern/include_opencv.h
39+
@@ -39,34 +39,34 @@
40+
#include <opencv2/highgui/highgui_winrt.hpp>
41+
#endif
42+
#include <opencv2/core/utils/logger.hpp>
43+
-#include <opencv2/highgui/highgui_c.h>
44+
+//#include <opencv2/highgui/highgui_c.h>
45+
#include <opencv2/imgproc/imgproc_c.h>
46+
-#include <opencv2/shape.hpp>
47+
-#include <opencv2/stitching.hpp>
48+
-#include <opencv2/video.hpp>
49+
+//#include <opencv2/shape.hpp>
50+
+//#include <opencv2/stitching.hpp>
51+
+//#include <opencv2/video.hpp>
52+
#ifndef _WINRT_DLL
53+
-#include <opencv2/superres.hpp>
54+
-#include <opencv2/superres/optical_flow.hpp>
55+
+//#include <opencv2/superres.hpp>
56+
+//#include <opencv2/superres/optical_flow.hpp>
57+
#endif
58+
59+
// opencv_contrib
60+
-#include <opencv2/aruco.hpp>
61+
-#include <opencv2/aruco/charuco.hpp>
62+
-#include <opencv2/bgsegm.hpp>
63+
-#include <opencv2/img_hash.hpp>
64+
-#include <opencv2/line_descriptor.hpp>
65+
-#include <opencv2/optflow.hpp>
66+
-#include <opencv2/quality.hpp>
67+
-#include <opencv2/tracking.hpp>
68+
-#include <opencv2/xfeatures2d.hpp>
69+
-#include <opencv2/ximgproc.hpp>
70+
-#include <opencv2/xphoto.hpp>
71+
+//#include <opencv2/aruco.hpp>
72+
+//#include <opencv2/aruco/charuco.hpp>
73+
+//#include <opencv2/bgsegm.hpp>
74+
+//#include <opencv2/img_hash.hpp>
75+
+//#include <opencv2/line_descriptor.hpp>
76+
+//#include <opencv2/optflow.hpp>
77+
+//#include <opencv2/quality.hpp>
78+
+//#include <opencv2/tracking.hpp>
79+
+//#include <opencv2/xfeatures2d.hpp>
80+
+//#include <opencv2/ximgproc.hpp>
81+
+//#include <opencv2/xphoto.hpp>
82+
#ifndef _WINRT_DLL
83+
-#include <opencv2/wechat_qrcode.hpp>
84+
-#include <opencv2/dnn.hpp>
85+
-#include <opencv2/dnn_superres.hpp>
86+
-#include <opencv2/face.hpp>
87+
-#include <opencv2/text.hpp>
88+
+//#include <opencv2/wechat_qrcode.hpp>
89+
+//#include <opencv2/dnn.hpp>
90+
+//#include <opencv2/dnn_superres.hpp>
91+
+//#include <opencv2/face.hpp>
92+
+//#include <opencv2/text.hpp>
93+
#endif
94+
95+
#include <vector>
96+
diff --git a/src/OpenCvSharpExtern/std_vector.h b/src/OpenCvSharpExtern/std_vector.h
97+
index b0699d03..5a398832 100644
98+
--- a/src/OpenCvSharpExtern/std_vector.h
99+
+++ b/src/OpenCvSharpExtern/std_vector.h
100+
@@ -448,6 +448,7 @@ CVAPI(void) vector_Mat_delete(std::vector<cv::Mat>* vector)
101+
}
102+
#pragma endregion
103+
104+
+#if 0
105+
#pragma region cv::ml::DTrees::Node
106+
107+
CVAPI(std::vector<cv::ml::DTrees::Node>*) vector_DTrees_Node_new1()
108+
@@ -582,4 +583,5 @@ CVAPI(void) vector_KeyLine_delete(std::vector<cv::line_descriptor::KeyLine>* vec
109+
delete vector;
110+
}
111+
#endif
112+
-#pragma endregion
113+
\ No newline at end of file
114+
+#pragma endregion
115+
+#endif

0 commit comments

Comments
 (0)