edgeConditionOptions();
-
- public static Builder builder() {
- return new AutoValue_ImageGenerator_ConditionOptions.Builder();
- }
-
- /**
- * Converts an {@link ImageGeneratorOptions} to a {@link CalculatorOptions} protobuf message.
- */
- @Override
- public Any convertToAnyProto() {
- ImageGeneratorGraphOptionsProto.ImageGeneratorGraphOptions.Builder taskOptionsBuilder =
- ImageGeneratorGraphOptionsProto.ImageGeneratorGraphOptions.newBuilder();
- if (faceConditionOptions().isPresent()) {
- taskOptionsBuilder.addControlPluginGraphsOptions(
- ControlPluginGraphOptionsProto.ControlPluginGraphOptions.newBuilder()
- .setBaseOptions(
- convertBaseOptionsToProto(faceConditionOptions().get().baseOptions()))
- .setConditionedImageGraphOptions(
- ConditionedImageGraphOptions.newBuilder()
- .setFaceConditionTypeOptions(faceConditionOptions().get().convertToProto())
- .build())
- .build());
- }
- if (edgeConditionOptions().isPresent()) {
- taskOptionsBuilder.addControlPluginGraphsOptions(
- ControlPluginGraphOptionsProto.ControlPluginGraphOptions.newBuilder()
- .setBaseOptions(
- convertBaseOptionsToProto(edgeConditionOptions().get().baseOptions()))
- .setConditionedImageGraphOptions(
- ConditionedImageGraphOptions.newBuilder()
- .setEdgeConditionTypeOptions(edgeConditionOptions().get().convertToProto())
- .build())
- .build());
- if (depthConditionOptions().isPresent()) {
- taskOptionsBuilder.addControlPluginGraphsOptions(
- ControlPluginGraphOptionsProto.ControlPluginGraphOptions.newBuilder()
- .setBaseOptions(
- convertBaseOptionsToProto(depthConditionOptions().get().baseOptions()))
- .setConditionedImageGraphOptions(
- ConditionedImageGraphOptions.newBuilder()
- .setDepthConditionTypeOptions(
- depthConditionOptions().get().convertToProto())
- .build())
- .build());
- }
- }
- return Any.newBuilder()
- .setTypeUrl(
- "type.googleapis.com/mediapipe.tasks.vision.image_generator.proto.ImageGeneratorGraphOptions")
- .setValue(taskOptionsBuilder.build().toByteString())
- .build();
- }
-
- /** Options for drawing face landmarks image. */
- @AutoValue
- public abstract static class FaceConditionOptions extends TaskOptions {
-
- /** Builder for {@link FaceConditionOptions}. */
- @AutoValue.Builder
- public abstract static class Builder {
- /** Set the base options for plugin model. */
- public abstract Builder setBaseOptions(BaseOptions baseOptions);
-
- /* {@link FaceLandmarkerOptions} used to detect face landmarks in the source image. */
- public abstract Builder setFaceLandmarkerOptions(
- FaceLandmarkerOptions faceLandmarkerOptions);
-
- abstract FaceConditionOptions autoBuild();
-
- /** Validates and builds the {@link FaceConditionOptions} instance. */
- public final FaceConditionOptions build() {
- return autoBuild();
- }
- }
-
- abstract BaseOptions baseOptions();
-
- abstract FaceLandmarkerOptions faceLandmarkerOptions();
-
- public static Builder builder() {
- return new AutoValue_ImageGenerator_ConditionOptions_FaceConditionOptions.Builder();
- }
-
- ConditionedImageGraphOptions.FaceConditionTypeOptions convertToProto() {
- return ConditionedImageGraphOptions.FaceConditionTypeOptions.newBuilder()
- .setFaceLandmarkerGraphOptions(
- FaceLandmarkerGraphOptions.newBuilder()
- .mergeFrom(
- faceLandmarkerOptions()
- .convertToCalculatorOptionsProto()
- .getExtension(FaceLandmarkerGraphOptions.ext))
- .build())
- .build();
- }
- }
-
- /** Options for detecting depth image. */
- @AutoValue
- public abstract static class DepthConditionOptions extends TaskOptions {
-
- /** Builder for {@link DepthConditionOptions}. */
- @AutoValue.Builder
- public abstract static class Builder {
-
- /** Set the base options for plugin model. */
- public abstract Builder setBaseOptions(BaseOptions baseOptions);
-
- /** {@link ImageSegmenterOptions} used to detect depth image from the source image. */
- public abstract Builder setImageSegmenterOptions(
- ImageSegmenterOptions imageSegmenterOptions);
-
- abstract DepthConditionOptions autoBuild();
-
- /** Validates and builds the {@link DepthConditionOptions} instance. */
- public final DepthConditionOptions build() {
- DepthConditionOptions options = autoBuild();
- return options;
- }
- }
-
- abstract BaseOptions baseOptions();
-
- abstract ImageSegmenterOptions imageSegmenterOptions();
-
- public static Builder builder() {
- return new AutoValue_ImageGenerator_ConditionOptions_DepthConditionOptions.Builder();
- }
-
- ConditionedImageGraphOptions.DepthConditionTypeOptions convertToProto() {
- return ConditionedImageGraphOptions.DepthConditionTypeOptions.newBuilder()
- .setImageSegmenterGraphOptions(
- imageSegmenterOptions()
- .convertToCalculatorOptionsProto()
- .getExtension(ImageSegmenterGraphOptions.ext))
- .build();
- }
- }
-
- /** Options for detecting edge image. */
- @AutoValue
- public abstract static class EdgeConditionOptions {
-
- /**
- * Builder for {@link EdgeConditionOptions}.
- *
- * These parameters are used to config Canny edge algorithm of OpenCV.
- *
- *
See more details:
- * https://docs.opencv.org/3.4/dd/d1a/group__imgproc__feature.html#ga04723e007ed888ddf11d9ba04e2232de
- */
- @AutoValue.Builder
- public abstract static class Builder {
-
- /** Set the base options for plugin model. */
- public abstract Builder setBaseOptions(BaseOptions baseOptions);
-
- /** First threshold for the hysteresis procedure. */
- public abstract Builder setThreshold1(Float threshold1);
-
- /** Second threshold for the hysteresis procedure. */
- public abstract Builder setThreshold2(Float threshold2);
-
- /** Aperture size for the Sobel operator. Typical range is 3~7. */
- public abstract Builder setApertureSize(Integer apertureSize);
-
- /**
- * flag, indicating whether a more accurate L2 norm should be used to calculate the image
- * gradient magnitude ( L2gradient=true ), or whether the default L1 norm is enough (
- * L2gradient=false ).
- */
- public abstract Builder setL2Gradient(Boolean l2Gradient);
-
- abstract EdgeConditionOptions autoBuild();
-
- /** Validates and builds the {@link EdgeConditionOptions} instance. */
- public final EdgeConditionOptions build() {
- return autoBuild();
- }
- }
-
- abstract BaseOptions baseOptions();
-
- abstract Float threshold1();
-
- abstract Float threshold2();
-
- abstract Integer apertureSize();
-
- abstract Boolean l2Gradient();
-
- public static Builder builder() {
- return new AutoValue_ImageGenerator_ConditionOptions_EdgeConditionOptions.Builder()
- .setThreshold1(100f)
- .setThreshold2(200f)
- .setApertureSize(3)
- .setL2Gradient(false);
- }
-
- ConditionedImageGraphOptions.EdgeConditionTypeOptions convertToProto() {
- return ConditionedImageGraphOptions.EdgeConditionTypeOptions.newBuilder()
- .setThreshold1(threshold1())
- .setThreshold2(threshold2())
- .setApertureSize(apertureSize())
- .setL2Gradient(l2Gradient())
- .build();
- }
- }
- }
-}
diff --git a/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/imagegenerator/ImageGeneratorResult.java b/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/imagegenerator/ImageGeneratorResult.java
deleted file mode 100644
index 6bb3ab60e..000000000
--- a/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/imagegenerator/ImageGeneratorResult.java
+++ /dev/null
@@ -1,44 +0,0 @@
-// 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.vision.imagegenerator;
-
-import com.google.auto.value.AutoValue;
-import com.google.mediapipe.framework.image.MPImage;
-import com.google.mediapipe.tasks.core.TaskResult;
-import java.util.Optional;
-
-/** Represents the image generation results generated by {@link ImageGenerator}. */
-@AutoValue
-public abstract class ImageGeneratorResult implements TaskResult {
-
- /** Create an {@link ImageGeneratorResult} instance from the generated image. */
- public static ImageGeneratorResult create(
- MPImage generatedImage, MPImage conditionImage, long timestampMs) {
- return new AutoValue_ImageGeneratorResult(
- generatedImage, Optional.of(conditionImage), timestampMs);
- }
-
- /** Create an {@link ImageGeneratorResult} instance from the generated image. */
- public static ImageGeneratorResult create(MPImage generatedImage, long timestampMs) {
- return new AutoValue_ImageGeneratorResult(generatedImage, Optional.empty(), timestampMs);
- }
-
- public abstract MPImage generatedImage();
-
- public abstract Optional conditionImage();
-
- @Override
- public abstract long timestampMs();
-}