forked from homuler/MediaPipeUnityPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mediapipe_opencv.diff
157 lines (155 loc) · 6.12 KB
/
mediapipe_opencv.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
diff --git a/third_party/BUILD b/third_party/BUILD
index 654f0cb..83e69ea 100644
--- a/third_party/BUILD
+++ b/third_party/BUILD
@@ -53,151 +53,12 @@ cc_library(
}),
)
-config_setting(
- name = "opencv_source_build",
- define_values = {
- "OPENCV": "source",
- },
- visibility = ["//visibility:public"],
-)
-
alias(
name = "opencv",
- actual = select({
- ":opencv_source_build": ":opencv_cmake",
- "//conditions:default": ":opencv_binary",
- }),
+ actual = "@opencv//:opencv",
visibility = ["//visibility:public"],
)
-load("@rules_foreign_cc//tools/build_defs:cmake.bzl", "cmake_external")
-
-# Note: this determines the order in which the libraries are passed to the
-# linker, so if library A depends on library B, library B must come _after_.
-# Hence core is at the bottom.
-OPENCV_MODULES = [
- "calib3d",
- "features2d",
- "highgui",
- "video",
- "videoio",
- "imgcodecs",
- "imgproc",
- "core",
-]
-
-# Note: passing both BUILD_SHARED_LIBS=ON and BUILD_STATIC_LIBS=ON to cmake
-# still only builds the shared libraries, so we have to choose one or the
-# other. We build shared libraries by default, but this variable can be used
-# to switch to static libraries.
-OPENCV_SHARED_LIBS = True
-
-OPENCV_SO_VERSION = "3.4"
-
-cmake_external(
- name = "opencv_cmake",
- # Values to be passed as -Dkey=value on the CMake command line;
- # here are serving to provide some CMake script configuration options
- cache_entries = {
- "CMAKE_BUILD_TYPE": "Release",
- # The module list is always sorted alphabetically so that we do not
- # cause a rebuild when changing the link order.
- "BUILD_LIST": ",".join(sorted(OPENCV_MODULES)),
- "BUILD_TESTS": "OFF",
- "BUILD_PERF_TESTS": "OFF",
- "BUILD_EXAMPLES": "OFF",
- "BUILD_SHARED_LIBS": "ON" if OPENCV_SHARED_LIBS else "OFF",
- "WITH_ITT": "OFF",
- "WITH_JASPER": "OFF",
- "WITH_JPEG": "ON",
- "WITH_PNG": "ON",
- "WITH_TIFF": "ON",
- "WITH_WEBP": "OFF",
- # Optimization flags
- "CV_ENABLE_INTRINSICS": "ON",
- "WITH_EIGEN": "ON",
- "WITH_PTHREADS": "ON",
- "WITH_PTHREADS_PF": "ON",
- # When building tests, by default Bazel builds them in dynamic mode.
- # See https://docs.bazel.build/versions/master/be/c-cpp.html#cc_binary.linkstatic
- # For example, when building //mediapipe/calculators/video:opencv_video_encoder_calculator_test,
- # the dependency //mediapipe/framework/formats:image_frame_opencv will
- # be built as a shared library, which depends on a cv::Mat constructor,
- # and expects it to be provided by the main exacutable. The main
- # executable depends on libimage_frame_opencv.so and links in
- # libopencv_core.a, which contains cv::Mat. However, if
- # libopencv_core.a marks its symbols as hidden, then cv::Mat is in
- # opencv_video_encoder_calculator_test but it is not exported, so
- # libimage_frame_opencv.so fails to find it.
- "OPENCV_SKIP_VISIBILITY_HIDDEN": "ON" if not OPENCV_SHARED_LIBS else "OFF",
- # The COPY actions in modules/python/python_loader.cmake have issues with symlinks.
- # In any case, we don't use this.
- "OPENCV_SKIP_PYTHON_LOADER": "ON",
- # Need to set this too, for the same reason.
- "BUILD_opencv_python": "OFF",
- # Ccache causes issues in some of our CI setups. It's not clear that
- # ccache would be able to work across sandboxed Bazel builds, either.
- # In any case, Bazel does its own caching of the rule's outputs.
- "ENABLE_CCACHE": "OFF",
- },
- lib_source = "@opencv//:all",
- linkopts = [] if OPENCV_SHARED_LIBS else [
- # When using static libraries, the binary that eventually depends on the
- # libraries also needs to link in their dependencies, which therefore
- # have to be listed here.
- # This list depends on which dependencies CMake finds when it configures
- # the build, and so depends on what is installed on the local system.
- # After building, the linkopts for the current setup can be extracted
- # from lib/pkgconfig/opencv.pc in bazel-out
- "-ljpeg",
- "-lpng",
- "-lz",
- "-ltiff",
- "-lImath",
- "-lIlmImf",
- "-lIex",
- "-lHalf",
- "-lIlmThread",
- "-ldc1394",
- "-lavcodec",
- "-lavformat",
- "-lavutil",
- "-lswscale",
- "-lavresample",
- "-ldl",
- "-lm",
- "-lpthread",
- "-lrt",
- ],
- shared_libraries = select({
- "@bazel_tools//src/conditions:darwin": ["libopencv_%s.%s.dylib" % (module, OPENCV_SO_VERSION) for module in OPENCV_MODULES],
- # Only the shared objects listed here will be linked in the directory
- # that Bazel adds to the RUNPATH of dependent executables. You cannot
- # list both the versioned and unversioned name of the .so, and the
- # versioned name is the one that the executables actually reference.
- "//conditions:default": ["libopencv_%s.so.%s" % (module, OPENCV_SO_VERSION) for module in OPENCV_MODULES],
- }) if OPENCV_SHARED_LIBS else None,
- static_libraries = [
- "libopencv_%s.a" % module
- for module in OPENCV_MODULES
- ] if not OPENCV_SHARED_LIBS else None,
-)
-
-alias(
- name = "opencv_binary",
- actual = select({
- "//mediapipe:android_x86": "@android_opencv//:libopencv_x86",
- "//mediapipe:android_x86_64": "@android_opencv//:libopencv_x86_64",
- "//mediapipe:android_armeabi": "@android_opencv//:libopencv_armeabi-v7a",
- "//mediapipe:android_arm": "@android_opencv//:libopencv_armeabi-v7a",
- "//mediapipe:android_arm64": "@android_opencv//:libopencv_arm64-v8a",
- "//mediapipe:ios": "@ios_opencv//:opencv",
- "//mediapipe:macos": "@macos_opencv//:opencv",
- "//mediapipe:windows": "@windows_opencv//:opencv",
- "//conditions:default": "@linux_opencv//:opencv",
- }),
-)
-
cc_library(
name = "libffmpeg",
visibility = ["//visibility:public"],