Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 651804743
  • Loading branch information
MediaPipe Team authored and copybara-github committed Jul 12, 2024
1 parent 65470a7 commit 6cd27ab
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 37 deletions.
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ http_archive(
build_file = "@//third_party:opencv_android.BUILD",
strip_prefix = "OpenCV-android-sdk",
type = "zip",
url = "https://github.com/opencv/opencv/releases/download/3.4.3/opencv-3.4.3-android-sdk.zip",
url = "https://github.com/opencv/opencv/releases/download/4.10.0/opencv-4.10.0-android-sdk.zip",
)

# After OpenCV 3.2.0, the pre-compiled opencv2.framework has google protobuf symbols, which will
Expand Down
19 changes: 0 additions & 19 deletions build_android_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@

set -e

function switch_to_opencv_3() {
echo "Switching to OpenCV 3"
sed -i -e 's:4.0.1/opencv-4.0.1:3.4.3/opencv-3.4.3:g' WORKSPACE
sed -i -e 's:libopencv_java4:libopencv_java3:g' third_party/opencv_android.BUILD
}

function switch_to_opencv_4() {
echo "Switching to OpenCV 4"
sed -i -e 's:3.4.3/opencv-3.4.3:4.0.1/opencv-4.0.1:g' WORKSPACE
sed -i -e 's:libopencv_java3:libopencv_java4:g' third_party/opencv_android.BUILD
}

out_dir="."
strip=true
install_only=false
Expand Down Expand Up @@ -76,7 +64,6 @@ echo "strip: $strip"

declare -a apks=()
declare -a bazel_flags
switch_to_opencv_3

apps="${app_dir}/*"
for app in ${apps}; do
Expand Down Expand Up @@ -117,14 +104,8 @@ for app in ${apps}; do
else
apk="${out_dir}/${target_name}.apk"
if [[ $install_only == false ]]; then
if [[ ${app_name} == "templatematchingcpu" ]]; then
switch_to_opencv_4
fi
bazelisk "${bazel_flags[@]}"
cp -f "${bin}" "${apk}"
if [[ ${app_name} == "templatematchingcpu" ]]; then
switch_to_opencv_3
fi
fi
apks+=(${apk})
fi
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started/hello_world_android.md
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ to load both dependencies:
static {
// Load all native libraries needed by the app.
System.loadLibrary("mediapipe_jni");
System.loadLibrary("opencv_java3");
System.loadLibrary("opencv_java4");
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,7 @@ public class MainActivity extends AppCompatActivity {
static {
// Load all native libraries needed by the app.
System.loadLibrary("mediapipe_jni");
try {
System.loadLibrary("opencv_java3");
} catch (java.lang.UnsatisfiedLinkError e) {
// Some example apps (e.g. template matching) require OpenCV 4.
System.loadLibrary("opencv_java4");
}
System.loadLibrary("opencv_java4");
}

// Sends camera-preview frames into a MediaPipe graph for processing, and displays the processed
Expand Down
8 changes: 4 additions & 4 deletions mediapipe/java/com/google/mediapipe/mediapipe_aar.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ def _mediapipe_jni(name, gen_libmediapipe, calculators = []):
native.cc_library(
name = name + "_opencv_cc_lib",
srcs = select({
"//mediapipe:android_arm64": ["@android_opencv//:libopencv_java3_so_arm64-v8a"],
"//mediapipe:android_arm": ["@android_opencv//:libopencv_java3_so_armeabi-v7a"],
"//mediapipe:android_x86": ["@android_opencv//:libopencv_java3_so_x86"],
"//mediapipe:android_x86_64": ["@android_opencv//:libopencv_java3_so_x86_64"],
"//mediapipe:android_arm64": ["@android_opencv//:libopencv_java4_so_arm64-v8a"],
"//mediapipe:android_arm": ["@android_opencv//:libopencv_java4_so_armeabi-v7a"],
"//mediapipe:android_x86": ["@android_opencv//:libopencv_java4_so_x86"],
"//mediapipe:android_x86_64": ["@android_opencv//:libopencv_java4_so_x86_64"],
"//conditions:default": [],
}),
alwayslink = 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,10 @@ def _mediapipe_tasks_aar(name, srcs, manifest, java_proto_lite_targets, native_l
native.cc_library(
name = name + "_jni_opencv_cc_lib",
srcs = select({
"//mediapipe:android_arm64": ["@android_opencv//:libopencv_java3_so_arm64-v8a"],
"//mediapipe:android_arm": ["@android_opencv//:libopencv_java3_so_armeabi-v7a"],
"//mediapipe:android_x86": ["@android_opencv//:libopencv_java3_so_x86"],
"//mediapipe:android_x86_64": ["@android_opencv//:libopencv_java3_so_x86_64"],
"//mediapipe:android_arm64": ["@android_opencv//:libopencv_java4_so_arm64-v8a"],
"//mediapipe:android_arm": ["@android_opencv//:libopencv_java4_so_armeabi-v7a"],
"//mediapipe:android_x86": ["@android_opencv//:libopencv_java4_so_x86"],
"//mediapipe:android_x86_64": ["@android_opencv//:libopencv_java4_so_x86_64"],
"//conditions:default": [],
}),
alwayslink = 1,
Expand Down
4 changes: 2 additions & 2 deletions third_party/opencv_android.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ licenses(["notice"]) # BSD license

exports_files(["LICENSE"])

OPENCV_LIBRARY_NAME = "libopencv_java3.so"
OPENCV_LIBRARY_NAME = "libopencv_java4.so"

OPENCVANDROIDSDK_NATIVELIBS_PATH = "sdk/native/libs/"

Expand All @@ -31,7 +31,7 @@ OPENCVANDROIDSDK_JNI_PATH = "sdk/native/jni/"
]]

[alias(
name = "libopencv_java3_so_" + arch,
name = "libopencv_java4_so_" + arch,
actual = OPENCVANDROIDSDK_NATIVELIBS_PATH + arch + "/" + OPENCV_LIBRARY_NAME,
visibility = ["//visibility:public"],
) for arch in [
Expand Down

0 comments on commit 6cd27ab

Please sign in to comment.