Add hand landmark named index constants
PiperOrigin-RevId: 489498248
This commit is contained in:
parent
2f361e2f47
commit
03d388fecf
|
@ -49,3 +49,8 @@ cc_library(
|
|||
"//mediapipe/tasks/cc/components/containers/proto:embeddings_cc_proto",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "landmark",
|
||||
hdrs = ["landmark.h"],
|
||||
)
|
||||
|
|
48
mediapipe/tasks/cc/components/containers/landmark.h
Normal file
48
mediapipe/tasks/cc/components/containers/landmark.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* Copyright 2022 The MediaPipe Authors. All Rights Reserved.
|
||||
|
||||
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.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef MEDIAPIPE_TASKS_CC_COMPONENTS_CONTAINERS_LANDMARK_H_
|
||||
#define MEDIAPIPE_TASKS_CC_COMPONENTS_CONTAINERS_LANDMARK_H_
|
||||
|
||||
namespace mediapipe::tasks::components::containers {
|
||||
|
||||
// The 21 hand landmarks.
|
||||
enum HandLandmark {
|
||||
WRIST = 0,
|
||||
THUMB_CMC = 1,
|
||||
THUMB_MCP = 2,
|
||||
THUMB_IP = 3,
|
||||
THUMB_TIP = 4,
|
||||
INDEX_FINGER_MCP = 5,
|
||||
INDEX_FINGER_PIP = 6,
|
||||
INDEX_FINGER_DIP = 7,
|
||||
INDEX_FINGER_TIP = 8,
|
||||
MIDDLE_FINGER_MCP = 9,
|
||||
MIDDLE_FINGER_PIP = 10,
|
||||
MIDDLE_FINGER_DIP = 11,
|
||||
MIDDLE_FINGER_TIP = 12,
|
||||
RING_FINGER_MCP = 13,
|
||||
RING_FINGER_PIP = 14,
|
||||
RING_FINGER_DIP = 15,
|
||||
RING_FINGER_TIP = 16,
|
||||
PINKY_MCP = 17,
|
||||
PINKY_PIP = 18,
|
||||
PINKY_DIP = 19,
|
||||
PINKY_TIP = 20
|
||||
};
|
||||
|
||||
} // namespace mediapipe::tasks::components::containers
|
||||
|
||||
#endif // MEDIAPIPE_TASKS_CC_COMPONENTS_CONTAINERS_LANDMARK_H_
|
|
@ -74,6 +74,18 @@ android_library(
|
|||
],
|
||||
)
|
||||
|
||||
android_library(
|
||||
name = "handlandmark",
|
||||
srcs = ["HandLandmark.java"],
|
||||
javacopts = [
|
||||
"-Xep:AndroidJdkLibsChecker:OFF",
|
||||
],
|
||||
deps = [
|
||||
"@maven//:androidx_annotation_annotation",
|
||||
"@maven//:com_google_guava_guava",
|
||||
],
|
||||
)
|
||||
|
||||
android_library(
|
||||
name = "landmark",
|
||||
srcs = ["Landmark.java"],
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
// Copyright 2022 The MediaPipe Authors. All Rights Reserved.
|
||||
//
|
||||
// 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.
|
||||
|
||||
package com.google.mediapipe.tasks.components.containers;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
|
||||
/** The 21 hand landmarks. */
|
||||
public final class HandLandmark {
|
||||
public static final int NUM_LANDMARKS = 21;
|
||||
|
||||
public static final int WRIST = 0;
|
||||
public static final int THUMB_CMC = 1;
|
||||
public static final int THUMB_MCP = 2;
|
||||
public static final int THUMB_IP = 3;
|
||||
public static final int THUMB_TIP = 4;
|
||||
public static final int INDEX_FINGER_MCP = 5;
|
||||
public static final int INDEX_FINGER_PIP = 6;
|
||||
public static final int INDEX_FINGER_DIP = 7;
|
||||
public static final int INDEX_FINGER_TIP = 8;
|
||||
public static final int MIDDLE_FINGER_MCP = 9;
|
||||
public static final int MIDDLE_FINGER_PIP = 10;
|
||||
public static final int MIDDLE_FINGER_DIP = 11;
|
||||
public static final int MIDDLE_FINGER_TIP = 12;
|
||||
public static final int RING_FINGER_MCP = 13;
|
||||
public static final int RING_FINGER_PIP = 14;
|
||||
public static final int RING_FINGER_DIP = 15;
|
||||
public static final int RING_FINGER_TIP = 16;
|
||||
public static final int PINKY_MCP = 17;
|
||||
public static final int PINKY_PIP = 18;
|
||||
public static final int PINKY_DIP = 19;
|
||||
public static final int PINKY_TIP = 20;
|
||||
|
||||
/** Represents a hand landmark type. */
|
||||
@IntDef({
|
||||
WRIST,
|
||||
THUMB_CMC,
|
||||
THUMB_MCP,
|
||||
THUMB_IP,
|
||||
THUMB_TIP,
|
||||
INDEX_FINGER_MCP,
|
||||
INDEX_FINGER_PIP,
|
||||
INDEX_FINGER_DIP,
|
||||
INDEX_FINGER_TIP,
|
||||
MIDDLE_FINGER_MCP,
|
||||
MIDDLE_FINGER_PIP,
|
||||
MIDDLE_FINGER_DIP,
|
||||
MIDDLE_FINGER_TIP,
|
||||
RING_FINGER_MCP,
|
||||
RING_FINGER_PIP,
|
||||
RING_FINGER_DIP,
|
||||
RING_FINGER_TIP,
|
||||
PINKY_MCP,
|
||||
PINKY_PIP,
|
||||
PINKY_DIP,
|
||||
PINKY_TIP,
|
||||
})
|
||||
public @interface HandLandmarkType {}
|
||||
|
||||
private HandLandmark() {}
|
||||
}
|
|
@ -14,6 +14,7 @@
|
|||
"""Landmark data class."""
|
||||
|
||||
import dataclasses
|
||||
import enum
|
||||
from typing import Optional
|
||||
|
||||
from mediapipe.framework.formats import landmark_pb2
|
||||
|
@ -120,3 +121,28 @@ class NormalizedLandmark:
|
|||
z=pb2_obj.z,
|
||||
visibility=pb2_obj.visibility,
|
||||
presence=pb2_obj.presence)
|
||||
|
||||
|
||||
class HandLandmark(enum.IntEnum):
|
||||
"""The 21 hand landmarks."""
|
||||
WRIST = 0
|
||||
THUMB_CMC = 1
|
||||
THUMB_MCP = 2
|
||||
THUMB_IP = 3
|
||||
THUMB_TIP = 4
|
||||
INDEX_FINGER_MCP = 5
|
||||
INDEX_FINGER_PIP = 6
|
||||
INDEX_FINGER_DIP = 7
|
||||
INDEX_FINGER_TIP = 8
|
||||
MIDDLE_FINGER_MCP = 9
|
||||
MIDDLE_FINGER_PIP = 10
|
||||
MIDDLE_FINGER_DIP = 11
|
||||
MIDDLE_FINGER_TIP = 12
|
||||
RING_FINGER_MCP = 13
|
||||
RING_FINGER_PIP = 14
|
||||
RING_FINGER_DIP = 15
|
||||
RING_FINGER_TIP = 16
|
||||
PINKY_MCP = 17
|
||||
PINKY_PIP = 18
|
||||
PINKY_DIP = 19
|
||||
PINKY_TIP = 20
|
||||
|
|
|
@ -33,3 +33,28 @@ export declare interface Landmark {
|
|||
/** Whether this landmark is normalized with respect to the image size. */
|
||||
normalized: boolean;
|
||||
}
|
||||
|
||||
/** The 21 hand landmarks. */
|
||||
export const enum HandLandmark {
|
||||
WRIST = 0,
|
||||
THUMB_CMC = 1,
|
||||
THUMB_MCP = 2,
|
||||
THUMB_IP = 3,
|
||||
THUMB_TIP = 4,
|
||||
INDEX_FINGER_MCP = 5,
|
||||
INDEX_FINGER_PIP = 6,
|
||||
INDEX_FINGER_DIP = 7,
|
||||
INDEX_FINGER_TIP = 8,
|
||||
MIDDLE_FINGER_MCP = 9,
|
||||
MIDDLE_FINGER_PIP = 10,
|
||||
MIDDLE_FINGER_DIP = 11,
|
||||
MIDDLE_FINGER_TIP = 12,
|
||||
RING_FINGER_MCP = 13,
|
||||
RING_FINGER_PIP = 14,
|
||||
RING_FINGER_DIP = 15,
|
||||
RING_FINGER_TIP = 16,
|
||||
PINKY_MCP = 17,
|
||||
PINKY_PIP = 18,
|
||||
PINKY_DIP = 19,
|
||||
PINKY_TIP = 20
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user