From 28e429c15d8db1e828afe7bc715e9c231f55a706 Mon Sep 17 00:00:00 2001 From: homuler Date: Sat, 20 Feb 2021 22:23:45 +0900 Subject: [PATCH] fix: not to flip input images horizontally when mediapipe outputs images --- .../Resources/instant_motion_tracking_android.txt | 8 ++++++++ .../Resources/instant_motion_tracking_gpu.txt | 10 ++++++++++ .../OfficialDemo/Resources/official_demo_android.txt | 7 +++---- .../Resources/official_demo_desktop_cpu.txt | 7 +++---- .../Resources/official_demo_desktop_gpu.txt | 7 +++---- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/Assets/MediaPipe/Examples/Graphs/InstantMotionTracking/Resources/instant_motion_tracking_android.txt b/Assets/MediaPipe/Examples/Graphs/InstantMotionTracking/Resources/instant_motion_tracking_android.txt index 0f53c8d8c..4378a58d2 100644 --- a/Assets/MediaPipe/Examples/Graphs/InstantMotionTracking/Resources/instant_motion_tracking_android.txt +++ b/Assets/MediaPipe/Examples/Graphs/InstantMotionTracking/Resources/instant_motion_tracking_android.txt @@ -12,6 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Copied from mediapipe/graphs/instant_motion_tracking/instant_motion_tracking.pbtxt +# +# CHANGES: +# - Remove GIF related inputs +# - Add ImageTransformationCalculator and flips the input +# - Add GlScalerCalculator and flips the output + # MediaPipe graph that performs region tracking and 3d object (AR sticker) rendering. # Images in/out of graph with sticker data and IMU information from device @@ -21,6 +28,7 @@ input_stream: "sticker_proto_string" input_stream: "imu_rotation_matrix" output_stream: "output_video" +# Flip vertically because the input image is aligned from bottom-left to top-right. node: { calculator: "ImageTransformationCalculator" input_stream: "IMAGE_GPU:input_video" diff --git a/Assets/MediaPipe/Examples/Graphs/InstantMotionTracking/Resources/instant_motion_tracking_gpu.txt b/Assets/MediaPipe/Examples/Graphs/InstantMotionTracking/Resources/instant_motion_tracking_gpu.txt index 10ae04b21..dbb0a7414 100644 --- a/Assets/MediaPipe/Examples/Graphs/InstantMotionTracking/Resources/instant_motion_tracking_gpu.txt +++ b/Assets/MediaPipe/Examples/Graphs/InstantMotionTracking/Resources/instant_motion_tracking_gpu.txt @@ -12,6 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Copied from mediapipe/graphs/instant_motion_tracking/instant_motion_tracking.pbtxt +# +# CHANGES: +# - Remove GIF related inputs +# - `input_video` is ImageFrame (ImageFrameToGpuBufferCalculator converts it into GpuBuffer) +# - Add ImageTransformationCalculator and flips the input +# - Add GlScalerCalculator and flips the output +# - `output_video` is ImageFrame + # MediaPipe graph that performs region tracking and 3d object (AR sticker) rendering. # Images in/out of graph with sticker data and IMU information from device @@ -27,6 +36,7 @@ node: { output_stream: "input_video_gpu" } +# Flip vertically because the input image is aligned from bottom-left to top-right. node: { calculator: "ImageTransformationCalculator" input_stream: "IMAGE_GPU:input_video_gpu" diff --git a/Assets/MediaPipe/Examples/Graphs/OfficialDemo/Resources/official_demo_android.txt b/Assets/MediaPipe/Examples/Graphs/OfficialDemo/Resources/official_demo_android.txt index 77d198fcf..c141db954 100644 --- a/Assets/MediaPipe/Examples/Graphs/OfficialDemo/Resources/official_demo_android.txt +++ b/Assets/MediaPipe/Examples/Graphs/OfficialDemo/Resources/official_demo_android.txt @@ -15,7 +15,7 @@ # This file is OfficialDemoAndroid's config file (Copied from mediapipe/graphs/hand_tracking/hand_tracking_mobile.pbtxt). # # CHANGES: -# - Add ImageTransformationCalculator and rotate the input +# - Add ImageTransformationCalculator and flips the input # - Add GlScalerCalculator and flips the output # MediaPipe graph that performs multi-hand tracking with TensorFlow Lite on GPU. @@ -55,15 +55,14 @@ node { output_stream: "throttled_input_video" } -# Flip vertically because the input image is aligned from bottom-left to top-right, -# and horizontally to use Web Camera. +# Flip vertically because the input image is aligned from bottom-left to top-right. node: { calculator: "ImageTransformationCalculator" input_stream: "IMAGE_GPU:throttled_input_video" output_stream: "IMAGE_GPU:transformed_input_video" node_options: { [type.googleapis.com/mediapipe.ImageTransformationCalculatorOptions] { - rotation_mode: 3 + flip_vertically: true } } } diff --git a/Assets/MediaPipe/Examples/Graphs/OfficialDemo/Resources/official_demo_desktop_cpu.txt b/Assets/MediaPipe/Examples/Graphs/OfficialDemo/Resources/official_demo_desktop_cpu.txt index ced6c8e13..a63493513 100644 --- a/Assets/MediaPipe/Examples/Graphs/OfficialDemo/Resources/official_demo_desktop_cpu.txt +++ b/Assets/MediaPipe/Examples/Graphs/OfficialDemo/Resources/official_demo_desktop_cpu.txt @@ -16,7 +16,7 @@ # # CHANGES: # - Add FlowLimiterCalculator -# - Add ImageTransformationCalculator and rotate the input +# - Add ImageTransformationCalculator and flips the input # - Use SidePacket instead of ConstantSidePacketCalculator # MediaPipe graph that performs hands tracking on desktop with TensorFlow @@ -41,15 +41,14 @@ node { output_stream: "throttled_input_video" } -# Flip vertically because the input image is aligned from bottom-left to top-right, -# and horizontally to use Web Camera. +# Flip vertically because the input image is aligned from bottom-left to top-right. node: { calculator: "ImageTransformationCalculator" input_stream: "IMAGE:throttled_input_video" output_stream: "IMAGE:transformed_input_video" node_options: { [type.googleapis.com/mediapipe.ImageTransformationCalculatorOptions] { - rotation_mode: 3 + flip_vertically: true } } } diff --git a/Assets/MediaPipe/Examples/Graphs/OfficialDemo/Resources/official_demo_desktop_gpu.txt b/Assets/MediaPipe/Examples/Graphs/OfficialDemo/Resources/official_demo_desktop_gpu.txt index 29a045722..30707bbac 100644 --- a/Assets/MediaPipe/Examples/Graphs/OfficialDemo/Resources/official_demo_desktop_gpu.txt +++ b/Assets/MediaPipe/Examples/Graphs/OfficialDemo/Resources/official_demo_desktop_gpu.txt @@ -16,7 +16,7 @@ # # CHANGES: # - `input_video` is ImageFrame (ImageFrameToGpuBufferCalculator converts it into GpuBuffer) -# - Add ImageTransformationCalculator and rotate the input +# - Add ImageTransformationCalculator and flips the input # - Add GlScalerCalculator and flips the output # - `output_video` is ImageFrame @@ -63,15 +63,14 @@ node: { output_stream: "throttled_input_video_gpu" } -# Flip vertically because the input image is aligned from bottom-left to top-right, -# and horizontally to use Web Camera. +# Flip vertically because the input image is aligned from bottom-left to top-right. node: { calculator: "ImageTransformationCalculator" input_stream: "IMAGE_GPU:throttled_input_video_gpu" output_stream: "IMAGE_GPU:transformed_input_video" node_options: { [type.googleapis.com/mediapipe.ImageTransformationCalculatorOptions] { - rotation_mode: 3 + flip_vertically: true } } }