From 473757c6ccffdeaf2dafde471d06edca46693b78 Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Tue, 19 Dec 2023 15:19:52 -0800 Subject: [PATCH] No public description PiperOrigin-RevId: 592358739 --- mediapipe/framework/port/build_config.bzl | 2 +- .../web/vision/holistic_landmarker/BUILD | 10 +++ .../holistic_landmarker.ts | 90 +++++++++++++++++++ .../tasks/web/vision/pose_landmarker/BUILD | 8 +- .../vision/pose_landmarker/pose_landmarker.ts | 9 +- .../pose_landmarks_connections.ts | 28 ++++++ 6 files changed, 138 insertions(+), 9 deletions(-) create mode 100644 mediapipe/tasks/web/vision/pose_landmarker/pose_landmarks_connections.ts diff --git a/mediapipe/framework/port/build_config.bzl b/mediapipe/framework/port/build_config.bzl index 41f04aba3..3d20ffa8a 100644 --- a/mediapipe/framework/port/build_config.bzl +++ b/mediapipe/framework/port/build_config.bzl @@ -26,7 +26,7 @@ def replace_suffix(string, old, new): def mediapipe_ts_library( name, - srcs, + srcs = [], visibility = None, deps = [], testonly = 0, diff --git a/mediapipe/tasks/web/vision/holistic_landmarker/BUILD b/mediapipe/tasks/web/vision/holistic_landmarker/BUILD index e13ec9614..89466ad08 100644 --- a/mediapipe/tasks/web/vision/holistic_landmarker/BUILD +++ b/mediapipe/tasks/web/vision/holistic_landmarker/BUILD @@ -15,6 +15,7 @@ mediapipe_ts_library( srcs = ["holistic_landmarker.ts"], visibility = ["//visibility:public"], deps = [ + ":holistic_landmarker_connections", ":holistic_landmarker_types", "//mediapipe/framework:calculator_jspb_proto", "//mediapipe/framework:calculator_options_jspb_proto", @@ -82,3 +83,12 @@ jasmine_node_test( tags = ["nomsan"], deps = [":holistic_landmarker_test_lib"], ) + +mediapipe_ts_library( + name = "holistic_landmarker_connections", + deps = [ + "//mediapipe/tasks/web/vision/face_landmarker:face_landmarks_connections", + "//mediapipe/tasks/web/vision/hand_landmarker:hand_landmarks_connections", + "//mediapipe/tasks/web/vision/pose_landmarker:pose_landmarks_connections", + ], +) diff --git a/mediapipe/tasks/web/vision/holistic_landmarker/holistic_landmarker.ts b/mediapipe/tasks/web/vision/holistic_landmarker/holistic_landmarker.ts index a9054bed5..c70515a92 100644 --- a/mediapipe/tasks/web/vision/holistic_landmarker/holistic_landmarker.ts +++ b/mediapipe/tasks/web/vision/holistic_landmarker/holistic_landmarker.ts @@ -34,6 +34,9 @@ import {convertToLandmarks, convertToWorldLandmarks} from '../../../../tasks/web import {WasmFileset} from '../../../../tasks/web/core/wasm_fileset'; import {ImageProcessingOptions} from '../../../../tasks/web/vision/core/image_processing_options'; import {VisionGraphRunner, VisionTaskRunner} from '../../../../tasks/web/vision/core/vision_task_runner'; +import {FACE_LANDMARKS_CONTOURS, FACE_LANDMARKS_FACE_OVAL, FACE_LANDMARKS_LEFT_EYE, FACE_LANDMARKS_LEFT_EYEBROW, FACE_LANDMARKS_LEFT_IRIS, FACE_LANDMARKS_LIPS, FACE_LANDMARKS_RIGHT_EYE, FACE_LANDMARKS_RIGHT_EYEBROW, FACE_LANDMARKS_RIGHT_IRIS, FACE_LANDMARKS_TESSELATION} from '../../../../tasks/web/vision/face_landmarker/face_landmarks_connections'; +import {HAND_CONNECTIONS} from '../../../../tasks/web/vision/hand_landmarker/hand_landmarks_connections'; +import {POSE_CONNECTIONS} from '../../../../tasks/web/vision/pose_landmarker/pose_landmarks_connections'; import {ImageSource, WasmModule} from '../../../../web/graph_runner/graph_runner'; // Placeholder for internal dependency on trusted resource url @@ -102,6 +105,93 @@ export class HolisticLandmarker extends VisionTaskRunner { private readonly poseLandmarksDetectorGraphOptions: PoseLandmarksDetectorGraphOptions; + /** + * An array containing the pairs of hand landmark indices to be rendered with + * connections. + * @export + * @nocollapse + */ + static HAND_CONNECTIONS = HAND_CONNECTIONS; + + /** + * An array containing the pairs of pose landmark indices to be rendered with + * connections. + * @export + * @nocollapse + */ + static POSE_CONNECTIONS = POSE_CONNECTIONS; + + /** + * Landmark connections to draw the connection between a face's lips. + * @export + * @nocollapse + */ + static FACE_LANDMARKS_LIPS = FACE_LANDMARKS_LIPS; + + /** + * Landmark connections to draw the connection between a face's left eye. + * @export + * @nocollapse + */ + static FACE_LANDMARKS_LEFT_EYE = FACE_LANDMARKS_LEFT_EYE; + + /** + * Landmark connections to draw the connection between a face's left eyebrow. + * @export + * @nocollapse + */ + static FACE_LANDMARKS_LEFT_EYEBROW = FACE_LANDMARKS_LEFT_EYEBROW; + + /** + * Landmark connections to draw the connection between a face's left iris. + * @export + * @nocollapse + */ + static FACE_LANDMARKS_LEFT_IRIS = FACE_LANDMARKS_LEFT_IRIS; + + /** + * Landmark connections to draw the connection between a face's right eye. + * @export + * @nocollapse + */ + static FACE_LANDMARKS_RIGHT_EYE = FACE_LANDMARKS_RIGHT_EYE; + + /** + * Landmark connections to draw the connection between a face's right + * eyebrow. + * @export + * @nocollapse + */ + static FACE_LANDMARKS_RIGHT_EYEBROW = FACE_LANDMARKS_RIGHT_EYEBROW; + + /** + * Landmark connections to draw the connection between a face's right iris. + * @export + * @nocollapse + */ + static FACE_LANDMARKS_RIGHT_IRIS = FACE_LANDMARKS_RIGHT_IRIS; + + /** + * Landmark connections to draw the face's oval. + * @export + * @nocollapse + */ + static FACE_LANDMARKS_FACE_OVAL = FACE_LANDMARKS_FACE_OVAL; + + /** + * Landmark connections to draw the face's contour. + * @export + * @nocollapse + */ + static FACE_LANDMARKS_CONTOURS = FACE_LANDMARKS_CONTOURS; + + /** + * Landmark connections to draw the face's tesselation. + * @export + * @nocollapse + */ + static FACE_LANDMARKS_TESSELATION = FACE_LANDMARKS_TESSELATION; + /** * Initializes the Wasm runtime and creates a new `HolisticLandmarker` from * the provided options. diff --git a/mediapipe/tasks/web/vision/pose_landmarker/BUILD b/mediapipe/tasks/web/vision/pose_landmarker/BUILD index ec4c0aeaf..b59b8a694 100644 --- a/mediapipe/tasks/web/vision/pose_landmarker/BUILD +++ b/mediapipe/tasks/web/vision/pose_landmarker/BUILD @@ -19,6 +19,7 @@ mediapipe_ts_library( visibility = ["//visibility:public"], deps = [ ":pose_landmarker_types", + ":pose_landmarks_connections", "//mediapipe/framework:calculator_jspb_proto", "//mediapipe/framework:calculator_options_jspb_proto", "//mediapipe/framework/formats:landmark_jspb_proto", @@ -32,7 +33,6 @@ mediapipe_ts_library( "//mediapipe/tasks/web/core", "//mediapipe/tasks/web/vision/core:image_processing_options", "//mediapipe/tasks/web/vision/core:mask", - "//mediapipe/tasks/web/vision/core:types", "//mediapipe/tasks/web/vision/core:vision_task_runner", "//mediapipe/web/graph_runner:graph_runner_ts", ], @@ -67,3 +67,9 @@ jasmine_node_test( tags = ["nomsan"], deps = [":pose_landmarker_test_lib"], ) + +mediapipe_ts_library( + name = "pose_landmarks_connections", + srcs = ["pose_landmarks_connections.ts"], + deps = ["//mediapipe/tasks/web/vision/core:types"], +) diff --git a/mediapipe/tasks/web/vision/pose_landmarker/pose_landmarker.ts b/mediapipe/tasks/web/vision/pose_landmarker/pose_landmarker.ts index c511d1cd4..c58d4dd08 100644 --- a/mediapipe/tasks/web/vision/pose_landmarker/pose_landmarker.ts +++ b/mediapipe/tasks/web/vision/pose_landmarker/pose_landmarker.ts @@ -26,13 +26,13 @@ import {convertToLandmarks, convertToWorldLandmarks} from '../../../../tasks/web import {WasmFileset} from '../../../../tasks/web/core/wasm_fileset'; import {ImageProcessingOptions} from '../../../../tasks/web/vision/core/image_processing_options'; import {MPMask} from '../../../../tasks/web/vision/core/mask'; -import {convertToConnections} from '../../../../tasks/web/vision/core/types'; import {VisionGraphRunner, VisionTaskRunner} from '../../../../tasks/web/vision/core/vision_task_runner'; import {ImageSource, WasmModule} from '../../../../web/graph_runner/graph_runner'; // Placeholder for internal dependency on trusted resource url import {PoseLandmarkerOptions} from './pose_landmarker_options'; import {PoseLandmarkerResult} from './pose_landmarker_result'; +import {POSE_CONNECTIONS} from './pose_landmarks_connections'; export * from './pose_landmarker_options'; export * from './pose_landmarker_result'; @@ -79,12 +79,7 @@ export class PoseLandmarker extends VisionTaskRunner { * @export * @nocollapse */ - static POSE_CONNECTIONS = convertToConnections( - [0, 1], [1, 2], [2, 3], [3, 7], [0, 4], [4, 5], [5, 6], [6, 8], [9, 10], - [11, 12], [11, 13], [13, 15], [15, 17], [15, 19], [15, 21], [17, 19], - [12, 14], [14, 16], [16, 18], [16, 20], [16, 22], [18, 20], [11, 23], - [12, 24], [23, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], - [28, 30], [29, 31], [30, 32], [27, 31], [28, 32]); + static POSE_CONNECTIONS = POSE_CONNECTIONS; /** * Initializes the Wasm runtime and creates a new `PoseLandmarker` from the diff --git a/mediapipe/tasks/web/vision/pose_landmarker/pose_landmarks_connections.ts b/mediapipe/tasks/web/vision/pose_landmarker/pose_landmarks_connections.ts new file mode 100644 index 000000000..2395ac2c7 --- /dev/null +++ b/mediapipe/tasks/web/vision/pose_landmarker/pose_landmarks_connections.ts @@ -0,0 +1,28 @@ +/** + * Copyright 2023 The MediaPipe Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {convertToConnections} from '../../../../tasks/web/vision/core/types'; + +/** + * An array containing the pairs of pose landmark indices to be rendered with + * connections. + */ +export const POSE_CONNECTIONS = convertToConnections( + [0, 1], [1, 2], [2, 3], [3, 7], [0, 4], [4, 5], [5, 6], [6, 8], [9, 10], + [11, 12], [11, 13], [13, 15], [15, 17], [15, 19], [15, 21], [17, 19], + [12, 14], [14, 16], [16, 18], [16, 20], [16, 22], [18, 20], [11, 23], + [12, 24], [23, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], + [28, 30], [29, 31], [30, 32], [27, 31], [28, 32]);