From e428bdb7e89aa101e442d05cc75157915f0ee5c3 Mon Sep 17 00:00:00 2001 From: Yuqi Li Date: Wed, 3 May 2023 13:32:20 -0700 Subject: [PATCH] internal change. PiperOrigin-RevId: 529181374 --- .../tasks/vision/core/BaseVisionTaskApi.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/core/BaseVisionTaskApi.java b/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/core/BaseVisionTaskApi.java index 070806522..5964cef2c 100644 --- a/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/core/BaseVisionTaskApi.java +++ b/mediapipe/tasks/java/com/google/mediapipe/tasks/vision/core/BaseVisionTaskApi.java @@ -77,11 +77,13 @@ public class BaseVisionTaskApi implements AutoCloseable { } Map inputPackets = new HashMap<>(); inputPackets.put(imageStreamName, runner.getPacketCreator().createImage(image)); - inputPackets.put( - normRectStreamName, - runner - .getPacketCreator() - .createProto(convertToNormalizedRect(imageProcessingOptions, image))); + if (!normRectStreamName.isEmpty()) { + inputPackets.put( + normRectStreamName, + runner + .getPacketCreator() + .createProto(convertToNormalizedRect(imageProcessingOptions, image))); + } return runner.process(inputPackets); } @@ -105,11 +107,13 @@ public class BaseVisionTaskApi implements AutoCloseable { } Map inputPackets = new HashMap<>(); inputPackets.put(imageStreamName, runner.getPacketCreator().createImage(image)); - inputPackets.put( - normRectStreamName, - runner - .getPacketCreator() - .createProto(convertToNormalizedRect(imageProcessingOptions, image))); + if (!normRectStreamName.isEmpty()) { + inputPackets.put( + normRectStreamName, + runner + .getPacketCreator() + .createProto(convertToNormalizedRect(imageProcessingOptions, image))); + } return runner.process(inputPackets, timestampMs * MICROSECONDS_PER_MILLISECOND); } @@ -133,11 +137,13 @@ public class BaseVisionTaskApi implements AutoCloseable { } Map inputPackets = new HashMap<>(); inputPackets.put(imageStreamName, runner.getPacketCreator().createImage(image)); - inputPackets.put( - normRectStreamName, - runner - .getPacketCreator() - .createProto(convertToNormalizedRect(imageProcessingOptions, image))); + if (!normRectStreamName.isEmpty()) { + inputPackets.put( + normRectStreamName, + runner + .getPacketCreator() + .createProto(convertToNormalizedRect(imageProcessingOptions, image))); + } runner.send(inputPackets, timestampMs * MICROSECONDS_PER_MILLISECOND); }