diff --git a/mediapipe/tasks/cc/components/containers/BUILD b/mediapipe/tasks/cc/components/containers/BUILD index dec977fb..35d3f478 100644 --- a/mediapipe/tasks/cc/components/containers/BUILD +++ b/mediapipe/tasks/cc/components/containers/BUILD @@ -49,8 +49,3 @@ cc_library( "//mediapipe/tasks/cc/components/containers/proto:embeddings_cc_proto", ], ) - -cc_library( - name = "landmark", - hdrs = ["landmark.h"], -) diff --git a/mediapipe/tasks/cc/vision/hand_landmarker/BUILD b/mediapipe/tasks/cc/vision/hand_landmarker/BUILD index 46948ee6..03ec45f7 100644 --- a/mediapipe/tasks/cc/vision/hand_landmarker/BUILD +++ b/mediapipe/tasks/cc/vision/hand_landmarker/BUILD @@ -54,6 +54,12 @@ cc_library( ], ) +cc_library( + name = "hand_landmark", + hdrs = ["hand_landmark.h"], + visibility = ["//visibility:public"], +) + cc_library( name = "hand_landmarks_detector_graph", srcs = ["hand_landmarks_detector_graph.cc"], diff --git a/mediapipe/tasks/cc/components/containers/landmark.h b/mediapipe/tasks/cc/vision/hand_landmarker/hand_landmark.h similarity index 78% rename from mediapipe/tasks/cc/components/containers/landmark.h rename to mediapipe/tasks/cc/vision/hand_landmarker/hand_landmark.h index 6fdd294a..c8dbc925 100644 --- a/mediapipe/tasks/cc/components/containers/landmark.h +++ b/mediapipe/tasks/cc/vision/hand_landmarker/hand_landmark.h @@ -13,10 +13,10 @@ 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_ +#ifndef MEDIAPIPE_TASKS_CC_VISION_HAND_LANDMARKER_HAND_LANDMARK_H_ +#define MEDIAPIPE_TASKS_CC_VISION_HAND_LANDMARKER_HAND_LANDMARK_H_ -namespace mediapipe::tasks::components::containers { +namespace mediapipe::tasks::vision::hand_landmarker { // The 21 hand landmarks. enum HandLandmark { @@ -43,6 +43,6 @@ enum HandLandmark { PINKY_TIP = 20 }; -} // namespace mediapipe::tasks::components::containers +} // namespace mediapipe::tasks::vision::hand_landmarker -#endif // MEDIAPIPE_TASKS_CC_COMPONENTS_CONTAINERS_LANDMARK_H_ +#endif // MEDIAPIPE_TASKS_CC_VISION_HAND_LANDMARKER_HAND_LANDMARK_H_ diff --git a/mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers/BUILD b/mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers/BUILD index 86915729..d6e6ac74 100644 --- a/mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers/BUILD +++ b/mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers/BUILD @@ -74,18 +74,6 @@ 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"], diff --git a/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/BUILD b/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/BUILD index 72cee133..b7febb11 100644 --- a/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/BUILD +++ b/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/BUILD @@ -145,6 +145,7 @@ android_library( android_library( name = "handlandmarker", srcs = [ + "handlandmarker/HandLandmark.java", "handlandmarker/HandLandmarker.java", "handlandmarker/HandLandmarkerResult.java", ], @@ -168,6 +169,7 @@ android_library( "//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:landmark", "//mediapipe/tasks/java/com/google/mediapipe/tasks/core", "//third_party:autovalue", + "@maven//:androidx_annotation_annotation", "@maven//:com_google_guava_guava", ], ) diff --git a/mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers/HandLandmark.java b/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/handlandmarker/HandLandmark.java similarity index 97% rename from mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers/HandLandmark.java rename to mediapipe/tasks/java/com/google/mediapipe/tasks/vision/handlandmarker/HandLandmark.java index da7c4e0c..7b21ebdd 100644 --- a/mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers/HandLandmark.java +++ b/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/handlandmarker/HandLandmark.java @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package com.google.mediapipe.tasks.components.containers; +package com.google.mediapipe.tasks.vision.handlandmarker; import androidx.annotation.IntDef; diff --git a/mediapipe/tasks/python/components/containers/landmark.py b/mediapipe/tasks/python/components/containers/landmark.py index 81b2943d..dee2a16a 100644 --- a/mediapipe/tasks/python/components/containers/landmark.py +++ b/mediapipe/tasks/python/components/containers/landmark.py @@ -14,7 +14,6 @@ """Landmark data class.""" import dataclasses -import enum from typing import Optional from mediapipe.framework.formats import landmark_pb2 @@ -121,28 +120,3 @@ 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 diff --git a/mediapipe/tasks/python/vision/hand_landmarker.py b/mediapipe/tasks/python/vision/hand_landmarker.py index 3367f1da..a0cd99a8 100644 --- a/mediapipe/tasks/python/vision/hand_landmarker.py +++ b/mediapipe/tasks/python/vision/hand_landmarker.py @@ -14,6 +14,7 @@ """MediaPipe hand landmarker task.""" import dataclasses +import enum from typing import Callable, Mapping, Optional, List from mediapipe.framework.formats import classification_pb2 @@ -53,6 +54,31 @@ _TASK_GRAPH_NAME = 'mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph' _MICRO_SECONDS_PER_MILLISECOND = 1000 +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 + + @dataclasses.dataclass class HandLandmarkerResult: """The hand landmarks result from HandLandmarker, where each vector element represents a single hand detected in the image. diff --git a/mediapipe/tasks/web/components/containers/landmark.d.ts b/mediapipe/tasks/web/components/containers/landmark.d.ts index 352717a2..c887303d 100644 --- a/mediapipe/tasks/web/components/containers/landmark.d.ts +++ b/mediapipe/tasks/web/components/containers/landmark.d.ts @@ -33,28 +33,3 @@ 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 -} diff --git a/mediapipe/tasks/web/vision/hand_landmarker/BUILD b/mediapipe/tasks/web/vision/hand_landmarker/BUILD index 1849687c..fc3e6ef1 100644 --- a/mediapipe/tasks/web/vision/hand_landmarker/BUILD +++ b/mediapipe/tasks/web/vision/hand_landmarker/BUILD @@ -34,6 +34,7 @@ mediapipe_ts_library( mediapipe_ts_declaration( name = "hand_landmarker_types", srcs = [ + "hand_landmark.d.ts", "hand_landmarker_options.d.ts", "hand_landmarker_result.d.ts", ], diff --git a/mediapipe/tasks/web/vision/hand_landmarker/hand_landmark.d.ts b/mediapipe/tasks/web/vision/hand_landmarker/hand_landmark.d.ts new file mode 100644 index 00000000..ca2543f7 --- /dev/null +++ b/mediapipe/tasks/web/vision/hand_landmarker/hand_landmark.d.ts @@ -0,0 +1,41 @@ +/** + * 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. + */ + + +/** 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 +}