Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin): mediapipe v0.8.10 #585

Merged
merged 4 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,20 @@ build:macos --cxxopt=-std=c++17
build:macos --host_cxxopt=-std=c++17
build:macos --copt=-w

build:darwin_x86_64 --apple_platform_type=macos
build:darwin_x86_64 --macos_minimum_os=10.12
build:darwin_x86_64 --cpu=darwin_x86_64

build:darwin_arm64 --apple_platform_type=macos
build:darwin_arm64 --macos_minimum_os=10.16
build:darwin_arm64 --cpu=darwin_arm64

# Sets the default Apple platform to macOS.
build --apple_platform_type=macos

# Compile ObjC++ files with C++17
build --per_file_copt=.*\.mm\$@-std=c++17

# Android configs.
# Note: the documentation tells us to use @androidndk//:default_crosstool, but
# the automatic configuration transition uses //external:android/crosstool.
Expand Down Expand Up @@ -58,6 +69,7 @@ build:android_fat --cpu=arm64-v8a
build:android_fat --fat_apk_cpu=armeabi-v7a,arm64-v8a

build:ios --apple_platform_type=ios
build:ios --copt=-fno-aligned-allocation

build:ios_i386 --config=ios
build:ios_i386 --cpu=ios_i386
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ protected override void DeleteMpPtr()
UnsafeNativeMethods.mp_GpuBuffer__delete(ptr);
}

#if UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX || UNITY_ANDROID
public GlTextureBuffer GetGlTextureBuffer()
{
return new GlTextureBuffer(SafeNativeMethods.mp_GpuBuffer__GetGlTextureBufferSharedPtr(mpPtr), false);
}
#endif

public GpuBufferFormat Format()
{
return SafeNativeMethods.mp_GpuBuffer__format(mpPtr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ namespace Mediapipe
{
internal static partial class SafeNativeMethods
{
#if UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX || UNITY_ANDROID
[Pure, DllImport(MediaPipeLibrary, ExactSpelling = true)]
public static extern IntPtr mp_GpuBuffer__GetGlTextureBufferSharedPtr(IntPtr gpuBuffer);
#endif

[Pure, DllImport(MediaPipeLibrary, ExactSpelling = true)]
public static extern int mp_GpuBuffer__width(IntPtr gpuBuffer);

Expand Down

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MediaPipe Unity Plugin

This is a Unity (2020.3.30f1) [Native Plugin](https://docs.unity3d.com/Manual/NativePlugins.html) to use [MediaPipe](https://github.com/google/mediapipe) (0.8.9).
This is a Unity (2020.3.30f1) [Native Plugin](https://docs.unity3d.com/Manual/NativePlugins.html) to use [MediaPipe](https://github.com/google/mediapipe) (0.8.10).

The goal of this project is to port the MediaPipe API (C++) _one by one_ to C# so that it can be called from Unity.\
This approach may sacrifice performance when you need to call multiple APIs in a loop, but it gives you the flexibility to use MediaPipe instead.
Expand Down
24 changes: 12 additions & 12 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ http_archive(
"@//third_party:mediapipe_visibility.diff",
"@//third_party:mediapipe_model_path.diff",
"@//third_party:mediapipe_extension.diff",
"@//third_party:mediapipe_emscripten_patch.diff",
# "@//third_party:mediapipe_emscripten_patch.diff",
],
sha256 = "54ce6da9f167d34fe53f928c804b3bc1fd1dd8fe2b32ca4bf0b63325d34680ac",
strip_prefix = "mediapipe-0.8.9",
urls = ["https://github.com/google/mediapipe/archive/v0.8.9.tar.gz"],
sha256 = "6b43a4304ca4aa3a698906e4b4ff696d698d0b788baffd8284c03632712b1020",
strip_prefix = "mediapipe-0.8.10",
urls = ["https://github.com/google/mediapipe/archive/v0.8.10.tar.gz"],
)

# ABSL cpp library lts_2021_03_24, patch 2.
Expand Down Expand Up @@ -122,12 +122,13 @@ http_archive(
urls = ["https://github.com/google/googletest/archive/4ec4cd23f486bf70efcc5d2caa40f24368f752e3.zip"],
)

# Google Benchmark library.
# Google Benchmark library v1.6.1 released on 2022-01-10.
http_archive(
name = "com_google_benchmark",
build_file = "@com_google_mediapipe//third_party:benchmark.BUILD",
strip_prefix = "benchmark-main",
urls = ["https://github.com/google/benchmark/archive/main.zip"],
sha256 = "6132883bc8c9b0df5375b16ab520fac1a85dc9e4cf5be59480448ece74b278d4",
strip_prefix = "benchmark-1.6.1",
urls = ["https://github.com/google/benchmark/archive/refs/tags/v1.6.1.tar.gz"],
)

# gflags needed by glog
Expand Down Expand Up @@ -399,10 +400,10 @@ http_archive(
)

# Tensorflow repo should always go after the other external dependencies.
# 2021-12-02
_TENSORFLOW_GIT_COMMIT = "18a1dc0ba806dc023808531f0373d9ec068e64bf"
# 2022-02-15
_TENSORFLOW_GIT_COMMIT = "a3419acc751dfc19caf4d34a1594e1f76810ec58"

_TENSORFLOW_SHA256 = "85b90416f7a11339327777bccd634de00ca0de2cf334f5f0727edcb11ff9289a"
_TENSORFLOW_SHA256 = "b95b2a83632d4055742ae1a2dcc96b45da6c12a339462dbc76c8bca505308e3a"

http_archive(
name = "org_tensorflow",
Expand All @@ -411,10 +412,9 @@ http_archive(
],
patches = [
"@com_google_mediapipe//third_party:org_tensorflow_compatibility_fixes.diff",
"@com_google_mediapipe//third_party:org_tensorflow_objc_cxx17.diff",
# Diff is generated with a script, don't update it manually.
"@com_google_mediapipe//third_party:org_tensorflow_custom_ops.diff",
"@//third_party:tensorflow_xnnpack_emscripten_fixes.diff",
# "@//third_party:tensorflow_xnnpack_emscripten_fixes.diff",
],
sha256 = _TENSORFLOW_SHA256,
strip_prefix = "tensorflow-%s" % _TENSORFLOW_GIT_COMMIT,
Expand Down
1 change: 1 addition & 0 deletions mediapipe_api/calculators/util/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ csharp_proto_src(
deps = [
"@com_google_mediapipe//mediapipe/calculators/util:protos_src",
"@com_google_mediapipe//mediapipe/framework:protos_src",
"@com_google_mediapipe//mediapipe/util:protos_src",
],
)

Expand Down
2 changes: 0 additions & 2 deletions mediapipe_api/gpu/gpu_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ MpReturnCode mp_GpuBuffer__PSgtb(SharedGlTextureBuffer* gl_texture_buffer, media
RETURN_CODE(MpReturnCode::Success);
CATCH_EXCEPTION
}

const SharedGlTextureBuffer& mp_GpuBuffer__GetGlTextureBufferSharedPtr(mediapipe::GpuBuffer* gpu_buffer) { return gpu_buffer->GetGlTextureBufferSharedPtr(); }
#endif // MEDIAPIPE_GPU_BUFFER_USE_CV_PIXEL_BUFFER

int mp_GpuBuffer__width(mediapipe::GpuBuffer* gpu_buffer) { return gpu_buffer->width(); }
Expand Down
1 change: 0 additions & 1 deletion mediapipe_api/gpu/gpu_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ MP_CAPI(void) mp_GpuBuffer__delete(mediapipe::GpuBuffer* gpu_buffer);
// TODO
#else
MP_CAPI(MpReturnCode) mp_GpuBuffer__PSgtb(SharedGlTextureBuffer* gl_texture_buffer, mediapipe::GpuBuffer** gpu_buffer_out);
MP_CAPI(const SharedGlTextureBuffer&) mp_GpuBuffer__GetGlTextureBufferSharedPtr(mediapipe::GpuBuffer* gpu_buffer);
#endif // MEDIAPIPE_GPU_BUFFER_USE_CV_PIXEL_BUFFER

MP_CAPI(int) mp_GpuBuffer__width(mediapipe::GpuBuffer* gpu_buffer);
Expand Down
8 changes: 4 additions & 4 deletions mediapipe_api/modules/iris_landmark/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ mediapipe_simple_subgraph(
graph = "iris_landmarks_from_face_landmarks_gpu.pbtxt",
register_as = "IrisLandmarksFromFaceLandmarksGpu",
deps = [
"@com_google_mediapipe//mediapipe/calculators/core:concatenate_normalized_landmark_list_calculator",
"@com_google_mediapipe//mediapipe/calculators/core:split_landmarks_calculator",
"@com_google_mediapipe//mediapipe/calculators/core:concatenate_proto_list_calculator",
"@com_google_mediapipe//mediapipe/calculators/core:split_proto_list_calculator",
"@com_google_mediapipe//mediapipe/graphs/iris_tracking/calculators:update_face_landmarks_calculator",
"@com_google_mediapipe//mediapipe/modules/iris_landmark:iris_landmark_left_and_right_gpu",
],
Expand All @@ -28,8 +28,8 @@ mediapipe_simple_subgraph(
graph = "iris_landmarks_from_face_landmarks_cpu.pbtxt",
register_as = "IrisLandmarksFromFaceLandmarksCpu",
deps = [
"@com_google_mediapipe//mediapipe/calculators/core:concatenate_normalized_landmark_list_calculator",
"@com_google_mediapipe//mediapipe/calculators/core:split_landmarks_calculator",
"@com_google_mediapipe//mediapipe/calculators/core:concatenate_proto_list_calculator",
"@com_google_mediapipe//mediapipe/calculators/core:split_proto_list_calculator",
"@com_google_mediapipe//mediapipe/graphs/iris_tracking/calculators:update_face_landmarks_calculator",
"@com_google_mediapipe//mediapipe/modules/iris_landmark:iris_landmark_left_and_right_cpu",
],
Expand Down
9 changes: 9 additions & 0 deletions mediapipe_api/util/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pkg_files(
srcs = [
":audio_decoder_cs",
":color_cs",
":label_map_cs",
":render_data_cs",
],
prefix = "Util",
Expand All @@ -52,6 +53,14 @@ csharp_proto_src(
],
)

csharp_proto_src(
name = "label_map_cs",
proto_src = "mediapipe/util/label_map.proto",
deps = [
"@com_google_mediapipe//mediapipe/util:protos_src",
],
)

csharp_proto_src(
name = "render_data_cs",
proto_src = "mediapipe/util/render_data.proto",
Expand Down
Loading