Add helper to create Connection array
PiperOrigin-RevId: 565706612
This commit is contained in:
parent
4a8a811373
commit
30590fe8d3
|
@ -1,7 +1,7 @@
|
||||||
# This package contains options shared by all MediaPipe Vision Tasks for Web.
|
# This package contains options shared by all MediaPipe Vision Tasks for Web.
|
||||||
|
|
||||||
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
|
|
||||||
load("//mediapipe/framework/port:build_config.bzl", "mediapipe_ts_declaration", "mediapipe_ts_library")
|
load("//mediapipe/framework/port:build_config.bzl", "mediapipe_ts_declaration", "mediapipe_ts_library")
|
||||||
|
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
|
||||||
|
|
||||||
package(default_visibility = ["//mediapipe/tasks:internal"])
|
package(default_visibility = ["//mediapipe/tasks:internal"])
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ mediapipe_ts_declaration(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
mediapipe_ts_declaration(
|
mediapipe_ts_library(
|
||||||
name = "types",
|
name = "types",
|
||||||
srcs = ["types.d.ts"],
|
srcs = ["types.ts"],
|
||||||
deps = [
|
deps = [
|
||||||
"//mediapipe/tasks/web/components/containers:keypoint",
|
"//mediapipe/tasks/web/components/containers:keypoint",
|
||||||
],
|
],
|
||||||
|
|
|
@ -30,3 +30,9 @@ export declare interface Connection {
|
||||||
start: number;
|
start: number;
|
||||||
end: number;
|
end: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Converts a list of connection in array notation to a list of Connections. */
|
||||||
|
export function convertToConnections(...connections: Array<[number, number]>):
|
||||||
|
Connection[] {
|
||||||
|
return connections.map(([start, end]) => ({start, end}));
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -14,18 +14,13 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Connection} from '../../../../tasks/web/vision/core/types';
|
import {convertToConnections} from '../../../../tasks/web/vision/core/types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array containing the pairs of hand landmark indices to be rendered with
|
* An array containing the pairs of hand landmark indices to be rendered with
|
||||||
* connections.
|
* connections.
|
||||||
*/
|
*/
|
||||||
export const HAND_CONNECTIONS: Connection[] = [
|
export const HAND_CONNECTIONS = convertToConnections(
|
||||||
{start: 0, end: 1}, {start: 1, end: 2}, {start: 2, end: 3},
|
[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [5, 9],
|
||||||
{start: 3, end: 4}, {start: 0, end: 5}, {start: 5, end: 6},
|
[9, 10], [10, 11], [11, 12], [9, 13], [13, 14], [14, 15], [15, 16],
|
||||||
{start: 6, end: 7}, {start: 7, end: 8}, {start: 5, end: 9},
|
[13, 17], [0, 17], [17, 18], [18, 19], [19, 20]);
|
||||||
{start: 9, end: 10}, {start: 10, end: 11}, {start: 11, end: 12},
|
|
||||||
{start: 9, end: 13}, {start: 13, end: 14}, {start: 14, end: 15},
|
|
||||||
{start: 15, end: 16}, {start: 13, end: 17}, {start: 0, end: 17},
|
|
||||||
{start: 17, end: 18}, {start: 18, end: 19}, {start: 19, end: 20}
|
|
||||||
];
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ 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 {Connection} from '../../../../tasks/web/vision/core/types';
|
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
|
||||||
|
@ -79,20 +79,12 @@ export class PoseLandmarker extends VisionTaskRunner {
|
||||||
* @export
|
* @export
|
||||||
* @nocollapse
|
* @nocollapse
|
||||||
*/
|
*/
|
||||||
static POSE_CONNECTIONS: Connection[] = [
|
static POSE_CONNECTIONS = convertToConnections(
|
||||||
{start: 0, end: 1}, {start: 1, end: 2}, {start: 2, end: 3},
|
[0, 1], [1, 2], [2, 3], [3, 7], [0, 4], [4, 5], [5, 6], [6, 8], [9, 10],
|
||||||
{start: 3, end: 7}, {start: 0, end: 4}, {start: 4, end: 5},
|
[11, 12], [11, 13], [13, 15], [15, 17], [15, 19], [15, 21], [17, 19],
|
||||||
{start: 5, end: 6}, {start: 6, end: 8}, {start: 9, end: 10},
|
[12, 14], [14, 16], [16, 18], [16, 20], [16, 22], [18, 20], [11, 23],
|
||||||
{start: 11, end: 12}, {start: 11, end: 13}, {start: 13, end: 15},
|
[12, 24], [23, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29],
|
||||||
{start: 15, end: 17}, {start: 15, end: 19}, {start: 15, end: 21},
|
[28, 30], [29, 31], [30, 32], [27, 31], [28, 32]);
|
||||||
{start: 17, end: 19}, {start: 12, end: 14}, {start: 14, end: 16},
|
|
||||||
{start: 16, end: 18}, {start: 16, end: 20}, {start: 16, end: 22},
|
|
||||||
{start: 18, end: 20}, {start: 11, end: 23}, {start: 12, end: 24},
|
|
||||||
{start: 23, end: 24}, {start: 23, end: 25}, {start: 24, end: 26},
|
|
||||||
{start: 25, end: 27}, {start: 26, end: 28}, {start: 27, end: 29},
|
|
||||||
{start: 28, end: 30}, {start: 29, end: 31}, {start: 30, end: 32},
|
|
||||||
{start: 27, end: 31}, {start: 28, end: 32}
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the Wasm runtime and creates a new `PoseLandmarker` from the
|
* Initializes the Wasm runtime and creates a new `PoseLandmarker` from the
|
||||||
|
|
Loading…
Reference in New Issue
Block a user