No public description

PiperOrigin-RevId: 592358739
This commit is contained in:
MediaPipe Team 2023-12-19 15:19:52 -08:00 committed by Copybara-Service
parent 7c3a5296ab
commit 473757c6cc
6 changed files with 138 additions and 9 deletions

View File

@ -26,7 +26,7 @@ def replace_suffix(string, old, new):
def mediapipe_ts_library( def mediapipe_ts_library(
name, name,
srcs, srcs = [],
visibility = None, visibility = None,
deps = [], deps = [],
testonly = 0, testonly = 0,

View File

@ -15,6 +15,7 @@ mediapipe_ts_library(
srcs = ["holistic_landmarker.ts"], srcs = ["holistic_landmarker.ts"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
":holistic_landmarker_connections",
":holistic_landmarker_types", ":holistic_landmarker_types",
"//mediapipe/framework:calculator_jspb_proto", "//mediapipe/framework:calculator_jspb_proto",
"//mediapipe/framework:calculator_options_jspb_proto", "//mediapipe/framework:calculator_options_jspb_proto",
@ -82,3 +83,12 @@ jasmine_node_test(
tags = ["nomsan"], tags = ["nomsan"],
deps = [":holistic_landmarker_test_lib"], 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",
],
)

View File

@ -34,6 +34,9 @@ import {convertToLandmarks, convertToWorldLandmarks} from '../../../../tasks/web
import {WasmFileset} from '../../../../tasks/web/core/wasm_fileset'; import {WasmFileset} from '../../../../tasks/web/core/wasm_fileset';
import {ImageProcessingOptions} from '../../../../tasks/web/vision/core/image_processing_options'; import {ImageProcessingOptions} from '../../../../tasks/web/vision/core/image_processing_options';
import {VisionGraphRunner, VisionTaskRunner} from '../../../../tasks/web/vision/core/vision_task_runner'; 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'; import {ImageSource, WasmModule} from '../../../../web/graph_runner/graph_runner';
// Placeholder for internal dependency on trusted resource url // Placeholder for internal dependency on trusted resource url
@ -102,6 +105,93 @@ export class HolisticLandmarker extends VisionTaskRunner {
private readonly poseLandmarksDetectorGraphOptions: private readonly poseLandmarksDetectorGraphOptions:
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 * Initializes the Wasm runtime and creates a new `HolisticLandmarker` from
* the provided options. * the provided options.

View File

@ -19,6 +19,7 @@ mediapipe_ts_library(
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
":pose_landmarker_types", ":pose_landmarker_types",
":pose_landmarks_connections",
"//mediapipe/framework:calculator_jspb_proto", "//mediapipe/framework:calculator_jspb_proto",
"//mediapipe/framework:calculator_options_jspb_proto", "//mediapipe/framework:calculator_options_jspb_proto",
"//mediapipe/framework/formats:landmark_jspb_proto", "//mediapipe/framework/formats:landmark_jspb_proto",
@ -32,7 +33,6 @@ mediapipe_ts_library(
"//mediapipe/tasks/web/core", "//mediapipe/tasks/web/core",
"//mediapipe/tasks/web/vision/core:image_processing_options", "//mediapipe/tasks/web/vision/core:image_processing_options",
"//mediapipe/tasks/web/vision/core:mask", "//mediapipe/tasks/web/vision/core:mask",
"//mediapipe/tasks/web/vision/core:types",
"//mediapipe/tasks/web/vision/core:vision_task_runner", "//mediapipe/tasks/web/vision/core:vision_task_runner",
"//mediapipe/web/graph_runner:graph_runner_ts", "//mediapipe/web/graph_runner:graph_runner_ts",
], ],
@ -67,3 +67,9 @@ jasmine_node_test(
tags = ["nomsan"], tags = ["nomsan"],
deps = [":pose_landmarker_test_lib"], deps = [":pose_landmarker_test_lib"],
) )
mediapipe_ts_library(
name = "pose_landmarks_connections",
srcs = ["pose_landmarks_connections.ts"],
deps = ["//mediapipe/tasks/web/vision/core:types"],
)

View File

@ -26,13 +26,13 @@ import {convertToLandmarks, convertToWorldLandmarks} from '../../../../tasks/web
import {WasmFileset} from '../../../../tasks/web/core/wasm_fileset'; import {WasmFileset} from '../../../../tasks/web/core/wasm_fileset';
import {ImageProcessingOptions} from '../../../../tasks/web/vision/core/image_processing_options'; import {ImageProcessingOptions} from '../../../../tasks/web/vision/core/image_processing_options';
import {MPMask} from '../../../../tasks/web/vision/core/mask'; 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 {VisionGraphRunner, VisionTaskRunner} from '../../../../tasks/web/vision/core/vision_task_runner';
import {ImageSource, WasmModule} from '../../../../web/graph_runner/graph_runner'; import {ImageSource, WasmModule} from '../../../../web/graph_runner/graph_runner';
// Placeholder for internal dependency on trusted resource url // Placeholder for internal dependency on trusted resource url
import {PoseLandmarkerOptions} from './pose_landmarker_options'; import {PoseLandmarkerOptions} from './pose_landmarker_options';
import {PoseLandmarkerResult} from './pose_landmarker_result'; import {PoseLandmarkerResult} from './pose_landmarker_result';
import {POSE_CONNECTIONS} from './pose_landmarks_connections';
export * from './pose_landmarker_options'; export * from './pose_landmarker_options';
export * from './pose_landmarker_result'; export * from './pose_landmarker_result';
@ -79,12 +79,7 @@ export class PoseLandmarker extends VisionTaskRunner {
* @export * @export
* @nocollapse * @nocollapse
*/ */
static POSE_CONNECTIONS = convertToConnections( static POSE_CONNECTIONS = POSE_CONNECTIONS;
[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]);
/** /**
* Initializes the Wasm runtime and creates a new `PoseLandmarker` from the * Initializes the Wasm runtime and creates a new `PoseLandmarker` from the

View File

@ -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]);