Skip to content

Commit

Permalink
feat: add Official Demo Graph
Browse files Browse the repository at this point in the history
  • Loading branch information
homuler committed Dec 28, 2020
1 parent 61d00a1 commit 7a340f9
Show file tree
Hide file tree
Showing 21 changed files with 515 additions and 155 deletions.
91 changes: 91 additions & 0 deletions Assets/MediaPipe/Examples/Objects/Graph/CPU/OfficialDemoCPU.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &3734263790809943474
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 577776907147759449}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e32f6ff63c1300ae0bc35516f44a9523, type: 3}
m_Name:
m_EditorClassIdentifier:
config: {fileID: 4900000, guid: 56381b940c26918b59d9eb15f793d01c, type: 3}
--- !u!1001 &5102661232923963756
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 5680418270291803701, guid: fc49226dfd774c66faf8a3dd6be53d0f,
type: 3}
propertyPath: m_Name
value: OfficialDemoCPU
objectReference: {fileID: 0}
- target: {fileID: 5680418270291803703, guid: fc49226dfd774c66faf8a3dd6be53d0f,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5680418270291803703, guid: fc49226dfd774c66faf8a3dd6be53d0f,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5680418270291803703, guid: fc49226dfd774c66faf8a3dd6be53d0f,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5680418270291803703, guid: fc49226dfd774c66faf8a3dd6be53d0f,
type: 3}
propertyPath: m_LocalPosition.z
value: -10
objectReference: {fileID: 0}
- target: {fileID: 5680418270291803703, guid: fc49226dfd774c66faf8a3dd6be53d0f,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5680418270291803703, guid: fc49226dfd774c66faf8a3dd6be53d0f,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5680418270291803703, guid: fc49226dfd774c66faf8a3dd6be53d0f,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5680418270291803703, guid: fc49226dfd774c66faf8a3dd6be53d0f,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5680418270291803703, guid: fc49226dfd774c66faf8a3dd6be53d0f,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5680418270291803703, guid: fc49226dfd774c66faf8a3dd6be53d0f,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5680418270291803703, guid: fc49226dfd774c66faf8a3dd6be53d0f,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents:
- {fileID: -5853697970282788592, guid: fc49226dfd774c66faf8a3dd6be53d0f, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: fc49226dfd774c66faf8a3dd6be53d0f, type: 3}
--- !u!1 &577776907147759449 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 5680418270291803701, guid: fc49226dfd774c66faf8a3dd6be53d0f,
type: 3}
m_PrefabInstance: {fileID: 5102661232923963756}
m_PrefabAsset: {fileID: 0}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions Assets/MediaPipe/Examples/Objects/Graph/GPU/OfficialDemoGPU.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5680418270291803701
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5680418270291803703}
- component: {fileID: -5853697970282788592}
m_Layer: 0
m_Name: OfficialDemoGPU
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5680418270291803703
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5680418270291803701}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &-5853697970282788592
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5680418270291803701}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 837c6eaee8d738102b379f9ce5dcd763, type: 3}
m_Name:
m_EditorClassIdentifier:
config: {fileID: 4900000, guid: 6c23f05384f6f0bb29afd72e99344a72, type: 3}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions Assets/MediaPipe/Examples/Resources/official_demo_cpu.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright 2019 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.

# This file is OfficialDemoCPU's config file.
#
# CHANGES:
# - add ImageTransformationCalculator
# - use SidePacket instead of ConstantSidePacketCalculator
# - add comments

# MediaPipe graph that performs hands tracking on desktop with TensorFlow
# Lite on CPU.
# Used in the example in
# mediapipe/examples/desktop/hand_tracking:hand_tracking_cpu.

# CPU image. (ImageFrame)
input_stream: "input_video"

# CPU image. (ImageFrame)
output_stream: "output_video"

# Flip vertically because the input image is aligned from bottom-left to top-right,
# and horizontally to use Web Camera.
node: {
calculator: "ImageTransformationCalculator"
input_stream: "IMAGE:input_video"
output_stream: "IMAGE:transformed_input_video"
node_options: {
[type.googleapis.com/mediapipe.ImageTransformationCalculatorOptions] {
rotation_mode: 3
}
}
}

# Detects/tracks hand landmarks.
node {
calculator: "HandLandmarkTrackingCpu"
input_stream: "IMAGE:transformed_input_video"
input_side_packet: "NUM_HANDS:num_hands"
output_stream: "LANDMARKS:landmarks"
output_stream: "HANDEDNESS:handedness"
output_stream: "PALM_DETECTIONS:multi_palm_detections"
output_stream: "HAND_ROIS_FROM_LANDMARKS:multi_hand_rects"
output_stream: "HAND_ROIS_FROM_PALM_DETECTIONS:multi_palm_rects"
}

# Subgraph that renders annotations and overlays them on top of the input
# images (see hand_renderer_cpu.pbtxt).
node {
calculator: "HandRendererSubgraph"
input_stream: "IMAGE:transformed_input_video"
input_stream: "DETECTIONS:multi_palm_detections"
input_stream: "LANDMARKS:landmarks"
input_stream: "HANDEDNESS:handedness"
input_stream: "NORM_RECTS:0:multi_palm_rects"
input_stream: "NORM_RECTS:1:multi_hand_rects"
output_stream: "IMAGE:output_video_raw"
}

# Flip vertically because the input image is aligned from top-left to bottom-right.
node: {
calculator: "ImageTransformationCalculator"
input_stream: "IMAGE:output_video_raw"
output_stream: "IMAGE:output_video"
node_options: {
[type.googleapis.com/mediapipe.ImageTransformationCalculatorOptions] {
flip_vertically: true
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

106 changes: 106 additions & 0 deletions Assets/MediaPipe/Examples/Resources/official_demo_gpu.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Copyright 2019 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.

# This file is OfficialDemoGPU's config file.
#
# CHANGES:
# - Add ImageTransformationCalculator
# - Add comments

# MediaPipe graph that performs multi-hand tracking with TensorFlow Lite on GPU.
# Used in the examples in
# mediapipe/examples/android/src/java/com/mediapipe/apps/handtrackinggpu.

# GPU image. (GpuBuffer)
input_stream: "input_video"

# Max number of hands to detect/process. (int)
input_side_packet: "num_hands"

# GPU image. (GpuBuffer)
output_stream: "output_video"
# Collection of detected/predicted hands, each represented as a list of
# landmarks. (std::vector<NormalizedLandmarkList>)
output_stream: "hand_landmarks"

# Throttles the images flowing downstream for flow control. It passes through
# the very first incoming image unaltered, and waits for downstream nodes
# (calculators and subgraphs) in the graph to finish their tasks before it
# passes through another image. All images that come in while waiting are
# dropped, limiting the number of in-flight images in most part of the graph to
# 1. This prevents the downstream nodes from queuing up incoming images and data
# excessively, which leads to increased latency and memory usage, unwanted in
# real-time mobile applications. It also eliminates unnecessarily computation,
# e.g., the output produced by a node may get dropped downstream if the
# subsequent nodes are still busy processing previous inputs.
node {
calculator: "FlowLimiterCalculator"
input_stream: "input_video"
input_stream: "FINISHED:output_video"
input_stream_info: {
tag_index: "FINISHED"
back_edge: true
}
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.
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
}
}
}

# Detects/tracks hand landmarks.
node {
calculator: "HandLandmarkTrackingGpu"
input_stream: "IMAGE:transformed_input_video"
input_side_packet: "NUM_HANDS:num_hands"
output_stream: "LANDMARKS:hand_landmarks"
output_stream: "HANDEDNESS:handedness"
output_stream: "PALM_DETECTIONS:palm_detections"
output_stream: "HAND_ROIS_FROM_LANDMARKS:hand_rects_from_landmarks"
output_stream: "HAND_ROIS_FROM_PALM_DETECTIONS:hand_rects_from_palm_detections"
}

# Subgraph that renders annotations and overlays them on top of the input
# images (see hand_renderer_gpu.pbtxt).
node {
calculator: "HandRendererSubgraph"
input_stream: "IMAGE:transformed_input_video"
input_stream: "DETECTIONS:palm_detections"
input_stream: "LANDMARKS:hand_landmarks"
input_stream: "HANDEDNESS:handedness"
input_stream: "NORM_RECTS:0:hand_rects_from_palm_detections"
input_stream: "NORM_RECTS:1:hand_rects_from_landmarks"
output_stream: "IMAGE:output_video_raw"
}

# Flip vertically because the output image is aligned from top-left to bottom-right.
node: {
calculator: "GlScalerCalculator"
input_stream: "VIDEO:output_video_raw"
output_stream: "VIDEO:output_video"
node_options: {
[type.googleapis.com/mediapipe.GlScalerCalculatorOptions] {
flip_vertical: true
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7a340f9

Please sign in to comment.