Move Java Connections arrays to Task class

PiperOrigin-RevId: 530719994
This commit is contained in:
Sebastian Schmidt 2023-05-09 14:50:26 -07:00 committed by Copybara-Service
parent 6f3c80ae8a
commit bea5eb766d
9 changed files with 141 additions and 60 deletions

View File

@ -80,6 +80,15 @@ android_library(
], ],
) )
android_library(
name = "connection",
srcs = ["Connection.java"],
deps = [
"//third_party:autovalue",
"@maven//:com_google_guava_guava",
],
)
android_library( android_library(
name = "landmark", name = "landmark",
srcs = ["Landmark.java"], srcs = ["Landmark.java"],

View File

@ -0,0 +1,29 @@
// 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.
package com.google.mediapipe.tasks.components.containers;
import com.google.auto.value.AutoValue;
/** Value class representing a landmark connection. */
@AutoValue
public abstract class Connection {
public static Connection create(int start, int end) {
return new AutoValue_Connection(start, end);
}
public abstract int start();
public abstract int end();
}

View File

@ -198,6 +198,7 @@ android_library(
"//mediapipe/tasks/cc/vision/pose_detector/proto:pose_detector_graph_options_java_proto_lite", "//mediapipe/tasks/cc/vision/pose_detector/proto:pose_detector_graph_options_java_proto_lite",
"//mediapipe/tasks/cc/vision/pose_landmarker/proto:pose_landmarker_graph_options_java_proto_lite", "//mediapipe/tasks/cc/vision/pose_landmarker/proto:pose_landmarker_graph_options_java_proto_lite",
"//mediapipe/tasks/cc/vision/pose_landmarker/proto:pose_landmarks_detector_graph_options_java_proto_lite", "//mediapipe/tasks/cc/vision/pose_landmarker/proto:pose_landmarks_detector_graph_options_java_proto_lite",
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:connection",
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:landmark", "//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:landmark",
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:normalized_landmark", "//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:normalized_landmark",
"//mediapipe/tasks/java/com/google/mediapipe/tasks/core", "//mediapipe/tasks/java/com/google/mediapipe/tasks/core",
@ -232,6 +233,7 @@ android_library(
"//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarker_graph_options_java_proto_lite", "//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarker_graph_options_java_proto_lite",
"//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarks_detector_graph_options_java_proto_lite", "//mediapipe/tasks/cc/vision/hand_landmarker/proto:hand_landmarks_detector_graph_options_java_proto_lite",
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:category", "//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:category",
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:connection",
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:landmark", "//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:landmark",
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:normalized_landmark", "//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:normalized_landmark",
"//mediapipe/tasks/java/com/google/mediapipe/tasks/core", "//mediapipe/tasks/java/com/google/mediapipe/tasks/core",
@ -373,6 +375,7 @@ android_library(
"//mediapipe/tasks/cc/vision/face_landmarker/proto:face_landmarker_graph_options_java_proto_lite", "//mediapipe/tasks/cc/vision/face_landmarker/proto:face_landmarker_graph_options_java_proto_lite",
"//mediapipe/tasks/cc/vision/face_landmarker/proto:face_landmarks_detector_graph_options_java_proto_lite", "//mediapipe/tasks/cc/vision/face_landmarker/proto:face_landmarks_detector_graph_options_java_proto_lite",
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:category", "//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:category",
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:connection",
"//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:normalized_landmark", "//mediapipe/tasks/java/com/google/mediapipe/tasks/components/containers:normalized_landmark",
"//mediapipe/tasks/java/com/google/mediapipe/tasks/core", "//mediapipe/tasks/java/com/google/mediapipe/tasks/core",
"//third_party:autovalue", "//third_party:autovalue",

View File

@ -25,6 +25,7 @@ import com.google.mediapipe.framework.Packet;
import com.google.mediapipe.framework.PacketGetter; import com.google.mediapipe.framework.PacketGetter;
import com.google.mediapipe.framework.image.BitmapImageBuilder; import com.google.mediapipe.framework.image.BitmapImageBuilder;
import com.google.mediapipe.framework.image.MPImage; import com.google.mediapipe.framework.image.MPImage;
import com.google.mediapipe.tasks.components.containers.Connection;
import com.google.mediapipe.tasks.core.BaseOptions; import com.google.mediapipe.tasks.core.BaseOptions;
import com.google.mediapipe.tasks.core.ErrorListener; import com.google.mediapipe.tasks.core.ErrorListener;
import com.google.mediapipe.tasks.core.OutputHandler; import com.google.mediapipe.tasks.core.OutputHandler;
@ -49,6 +50,7 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
/** /**
* Performs face landmarks detection on images. * Performs face landmarks detection on images.
@ -223,6 +225,46 @@ public final class FaceLandmarker extends BaseVisionTaskApi {
return new FaceLandmarker(runner, landmarkerOptions.runningMode()); return new FaceLandmarker(runner, landmarkerOptions.runningMode());
} }
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_LIPS =
FaceLandmarksConnections.FACE_LANDMARKS_LIPS;
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_LEFT_EYE =
FaceLandmarksConnections.FACE_LANDMARKS_LEFT_EYE;
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_LEFT_EYE_BROW =
FaceLandmarksConnections.FACE_LANDMARKS_LEFT_EYE_BROW;
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_LEFT_IRIS =
FaceLandmarksConnections.FACE_LANDMARKS_LEFT_IRIS;
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_RIGHT_EYE =
FaceLandmarksConnections.FACE_LANDMARKS_RIGHT_EYE;
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_RIGHT_EYE_BROW =
FaceLandmarksConnections.FACE_LANDMARKS_RIGHT_EYE_BROW;
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_RIGHT_IRIS =
FaceLandmarksConnections.FACE_LANDMARKS_RIGHT_IRIS;
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_FACE_OVAL =
FaceLandmarksConnections.FACE_LANDMARKS_FACE_OVAL;
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_CONNECTORS =
FaceLandmarksConnections.FACE_LANDMARKS_CONNECTORS;
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_TESSELATION =
FaceLandmarksConnections.FACE_LANDMARKS_TESSELATION;
/** /**
* Constructor to initialize an {@link FaceLandmarker} from a {@link TaskRunner} and a {@link * Constructor to initialize an {@link FaceLandmarker} from a {@link TaskRunner} and a {@link
* RunningMode}. * RunningMode}.

View File

@ -14,7 +14,7 @@
package com.google.mediapipe.tasks.vision.facelandmarker; package com.google.mediapipe.tasks.vision.facelandmarker;
import com.google.auto.value.AutoValue; import com.google.mediapipe.tasks.components.containers.Connection;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
@ -23,22 +23,10 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
/** Face landmarks connection constants. */ /** Face landmarks connection constants. */
public final class FaceLandmarksConnections { final class FaceLandmarksConnections {
/** Value class representing face landmarks connection. */
@AutoValue
public abstract static class Connection {
static Connection create(int start, int end) {
return new AutoValue_FaceLandmarksConnections_Connection(start, end);
}
public abstract int start();
public abstract int end();
}
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_LIPS = static final Set<Connection> FACE_LANDMARKS_LIPS =
Collections.unmodifiableSet( Collections.unmodifiableSet(
new HashSet<>( new HashSet<>(
Arrays.asList( Arrays.asList(
@ -84,7 +72,7 @@ public final class FaceLandmarksConnections {
Connection.create(415, 308)))); Connection.create(415, 308))));
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_LEFT_EYE = static final Set<Connection> FACE_LANDMARKS_LEFT_EYE =
Collections.unmodifiableSet( Collections.unmodifiableSet(
new HashSet<>( new HashSet<>(
Arrays.asList( Arrays.asList(
@ -106,7 +94,7 @@ public final class FaceLandmarksConnections {
Connection.create(398, 362)))); Connection.create(398, 362))));
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_LEFT_EYE_BROW = static final Set<Connection> FACE_LANDMARKS_LEFT_EYE_BROW =
Collections.unmodifiableSet( Collections.unmodifiableSet(
new HashSet<>( new HashSet<>(
Arrays.asList( Arrays.asList(
@ -120,7 +108,7 @@ public final class FaceLandmarksConnections {
Connection.create(296, 336)))); Connection.create(296, 336))));
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_LEFT_IRIS = static final Set<Connection> FACE_LANDMARKS_LEFT_IRIS =
Collections.unmodifiableSet( Collections.unmodifiableSet(
new HashSet<>( new HashSet<>(
Arrays.asList( Arrays.asList(
@ -130,7 +118,7 @@ public final class FaceLandmarksConnections {
Connection.create(477, 474)))); Connection.create(477, 474))));
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_RIGHT_EYE = static final Set<Connection> FACE_LANDMARKS_RIGHT_EYE =
Collections.unmodifiableSet( Collections.unmodifiableSet(
new HashSet<>( new HashSet<>(
Arrays.asList( Arrays.asList(
@ -152,7 +140,7 @@ public final class FaceLandmarksConnections {
Connection.create(173, 133)))); Connection.create(173, 133))));
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_RIGHT_EYE_BROW = static final Set<Connection> FACE_LANDMARKS_RIGHT_EYE_BROW =
Collections.unmodifiableSet( Collections.unmodifiableSet(
new HashSet<>( new HashSet<>(
Arrays.asList( Arrays.asList(
@ -166,7 +154,7 @@ public final class FaceLandmarksConnections {
Connection.create(66, 107)))); Connection.create(66, 107))));
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_RIGHT_IRIS = static final Set<Connection> FACE_LANDMARKS_RIGHT_IRIS =
Collections.unmodifiableSet( Collections.unmodifiableSet(
new HashSet<>( new HashSet<>(
Arrays.asList( Arrays.asList(
@ -176,7 +164,7 @@ public final class FaceLandmarksConnections {
Connection.create(472, 469)))); Connection.create(472, 469))));
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_FACE_OVAL = static final Set<Connection> FACE_LANDMARKS_FACE_OVAL =
Collections.unmodifiableSet( Collections.unmodifiableSet(
new HashSet<>( new HashSet<>(
Arrays.asList( Arrays.asList(
@ -218,7 +206,7 @@ public final class FaceLandmarksConnections {
Connection.create(109, 10)))); Connection.create(109, 10))));
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_CONNECTORS = static final Set<Connection> FACE_LANDMARKS_CONNECTORS =
Collections.unmodifiableSet( Collections.unmodifiableSet(
Stream.of( Stream.of(
FACE_LANDMARKS_LIPS.stream(), FACE_LANDMARKS_LIPS.stream(),
@ -231,7 +219,7 @@ public final class FaceLandmarksConnections {
.collect(Collectors.toSet())); .collect(Collectors.toSet()));
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> FACE_LANDMARKS_TESSELATION = static final Set<Connection> FACE_LANDMARKS_TESSELATION =
Collections.unmodifiableSet( Collections.unmodifiableSet(
new HashSet<>( new HashSet<>(
Arrays.asList( Arrays.asList(

View File

@ -26,6 +26,7 @@ import com.google.mediapipe.framework.Packet;
import com.google.mediapipe.framework.PacketGetter; import com.google.mediapipe.framework.PacketGetter;
import com.google.mediapipe.framework.image.BitmapImageBuilder; import com.google.mediapipe.framework.image.BitmapImageBuilder;
import com.google.mediapipe.framework.image.MPImage; import com.google.mediapipe.framework.image.MPImage;
import com.google.mediapipe.tasks.components.containers.Connection;
import com.google.mediapipe.tasks.core.BaseOptions; import com.google.mediapipe.tasks.core.BaseOptions;
import com.google.mediapipe.tasks.core.ErrorListener; import com.google.mediapipe.tasks.core.ErrorListener;
import com.google.mediapipe.tasks.core.OutputHandler; import com.google.mediapipe.tasks.core.OutputHandler;
@ -48,6 +49,7 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
/** /**
* Performs hand landmarks detection on images. * Performs hand landmarks detection on images.
@ -195,6 +197,33 @@ public final class HandLandmarker extends BaseVisionTaskApi {
return new HandLandmarker(runner, landmarkerOptions.runningMode()); return new HandLandmarker(runner, landmarkerOptions.runningMode());
} }
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> HAND_PALM_CONNECTIONS =
HandLandmarksConnections.HAND_PALM_CONNECTIONS;
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> HAND_THUMB_CONNECTIONS =
HandLandmarksConnections.HAND_THUMB_CONNECTIONS;
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> HAND_INDEX_FINGER_CONNECTIONS =
HandLandmarksConnections.HAND_INDEX_FINGER_CONNECTIONS;
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> HAND_MIDDLE_FINGER_CONNECTIONS =
HandLandmarksConnections.HAND_MIDDLE_FINGER_CONNECTIONS;
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> HAND_RING_FINGER_CONNECTIONS =
HandLandmarksConnections.HAND_RING_FINGER_CONNECTIONS;
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> HAND_PINKY_FINGER_CONNECTIONS =
HandLandmarksConnections.HAND_PINKY_FINGER_CONNECTIONS;
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> HAND_CONNECTIONS = HandLandmarksConnections.HAND_CONNECTIONS;
/** /**
* Constructor to initialize an {@link HandLandmarker} from a {@link TaskRunner} and a {@link * Constructor to initialize an {@link HandLandmarker} from a {@link TaskRunner} and a {@link
* RunningMode}. * RunningMode}.

View File

@ -14,7 +14,7 @@
package com.google.mediapipe.tasks.vision.handlandmarker; package com.google.mediapipe.tasks.vision.handlandmarker;
import com.google.auto.value.AutoValue; import com.google.mediapipe.tasks.components.containers.Connection;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
@ -23,22 +23,10 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
/** Hand landmarks connection constants. */ /** Hand landmarks connection constants. */
public final class HandLandmarksConnections { final class HandLandmarksConnections {
/** Value class representing hand landmarks connection. */
@AutoValue
public abstract static class Connection {
static Connection create(int start, int end) {
return new AutoValue_HandLandmarksConnections_Connection(start, end);
}
public abstract int start();
public abstract int end();
}
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> HAND_PALM_CONNECTIONS = static final Set<Connection> HAND_PALM_CONNECTIONS =
Collections.unmodifiableSet( Collections.unmodifiableSet(
new HashSet<>( new HashSet<>(
Arrays.asList( Arrays.asList(
@ -50,28 +38,28 @@ public final class HandLandmarksConnections {
Connection.create(0, 17)))); Connection.create(0, 17))));
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> HAND_THUMB_CONNECTIONS = static final Set<Connection> HAND_THUMB_CONNECTIONS =
Collections.unmodifiableSet( Collections.unmodifiableSet(
new HashSet<>( new HashSet<>(
Arrays.asList( Arrays.asList(
Connection.create(1, 2), Connection.create(2, 3), Connection.create(3, 4)))); Connection.create(1, 2), Connection.create(2, 3), Connection.create(3, 4))));
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> HAND_INDEX_FINGER_CONNECTIONS = static final Set<Connection> HAND_INDEX_FINGER_CONNECTIONS =
Collections.unmodifiableSet( Collections.unmodifiableSet(
new HashSet<>( new HashSet<>(
Arrays.asList( Arrays.asList(
Connection.create(5, 6), Connection.create(6, 7), Connection.create(7, 8)))); Connection.create(5, 6), Connection.create(6, 7), Connection.create(7, 8))));
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> HAND_MIDDLE_FINGER_CONNECTIONS = static final Set<Connection> HAND_MIDDLE_FINGER_CONNECTIONS =
Collections.unmodifiableSet( Collections.unmodifiableSet(
new HashSet<>( new HashSet<>(
Arrays.asList( Arrays.asList(
Connection.create(9, 10), Connection.create(10, 11), Connection.create(11, 12)))); Connection.create(9, 10), Connection.create(10, 11), Connection.create(11, 12))));
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> HAND_RING_FINGER_CONNECTIONS = static final Set<Connection> HAND_RING_FINGER_CONNECTIONS =
Collections.unmodifiableSet( Collections.unmodifiableSet(
new HashSet<>( new HashSet<>(
Arrays.asList( Arrays.asList(
@ -80,7 +68,7 @@ public final class HandLandmarksConnections {
Connection.create(15, 16)))); Connection.create(15, 16))));
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> HAND_PINKY_FINGER_CONNECTIONS = static final Set<Connection> HAND_PINKY_FINGER_CONNECTIONS =
Collections.unmodifiableSet( Collections.unmodifiableSet(
new HashSet<>( new HashSet<>(
Arrays.asList( Arrays.asList(
@ -89,7 +77,7 @@ public final class HandLandmarksConnections {
Connection.create(19, 20)))); Connection.create(19, 20))));
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> HAND_CONNECTIONS = static final Set<Connection> HAND_CONNECTIONS =
Collections.unmodifiableSet( Collections.unmodifiableSet(
Stream.of( Stream.of(
HAND_PALM_CONNECTIONS.stream(), HAND_PALM_CONNECTIONS.stream(),

View File

@ -27,6 +27,7 @@ import com.google.mediapipe.framework.PacketGetter;
import com.google.mediapipe.framework.image.BitmapImageBuilder; import com.google.mediapipe.framework.image.BitmapImageBuilder;
import com.google.mediapipe.framework.image.ByteBufferImageBuilder; import com.google.mediapipe.framework.image.ByteBufferImageBuilder;
import com.google.mediapipe.framework.image.MPImage; import com.google.mediapipe.framework.image.MPImage;
import com.google.mediapipe.tasks.components.containers.Connection;
import com.google.mediapipe.tasks.core.BaseOptions; import com.google.mediapipe.tasks.core.BaseOptions;
import com.google.mediapipe.tasks.core.ErrorListener; import com.google.mediapipe.tasks.core.ErrorListener;
import com.google.mediapipe.tasks.core.OutputHandler; import com.google.mediapipe.tasks.core.OutputHandler;
@ -49,6 +50,7 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
/** /**
* Performs pose landmarks detection on images. * Performs pose landmarks detection on images.
@ -206,6 +208,9 @@ public final class PoseLandmarker extends BaseVisionTaskApi {
return new PoseLandmarker(runner, landmarkerOptions.runningMode()); return new PoseLandmarker(runner, landmarkerOptions.runningMode());
} }
@SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> POSE_LANDMARKS = PoseLandmarksConnections.POSE_LANDMARKS;
/** /**
* Constructor to initialize a {@link PoseLandmarker} from a {@link TaskRunner} and a {@link * Constructor to initialize a {@link PoseLandmarker} from a {@link TaskRunner} and a {@link
* RunningMode}. * RunningMode}.

View File

@ -14,29 +14,17 @@
package com.google.mediapipe.tasks.vision.poselandmarker; package com.google.mediapipe.tasks.vision.poselandmarker;
import com.google.auto.value.AutoValue; import com.google.mediapipe.tasks.components.containers.Connection;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
/** Pose landmarks connection constants. */ /** Pose landmarks connection constants. */
public final class PoseLandmarksConnections { final class PoseLandmarksConnections {
/** Value class representing pose landmarks connection. */
@AutoValue
public abstract static class Connection {
static Connection create(int start, int end) {
return new AutoValue_PoseLandmarksConnections_Connection(start, end);
}
public abstract int start();
public abstract int end();
}
@SuppressWarnings("ConstantCaseForConstants") @SuppressWarnings("ConstantCaseForConstants")
public static final Set<Connection> POSE_LANDMARKS = static final Set<Connection> POSE_LANDMARKS =
Collections.unmodifiableSet( Collections.unmodifiableSet(
new HashSet<>( new HashSet<>(
Arrays.asList( Arrays.asList(