-
-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!1 &5607713704072404419 | ||
GameObject: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
serializedVersion: 6 | ||
m_Component: | ||
- component: {fileID: 5607713704072404417} | ||
- component: {fileID: -2811934882097957570} | ||
- component: {fileID: -5097301488528543352} | ||
m_Layer: 0 | ||
m_Name: HolisticDesktopGPU | ||
m_TagString: Untagged | ||
m_Icon: {fileID: 0} | ||
m_NavMeshLayer: 0 | ||
m_StaticEditorFlags: 0 | ||
m_IsActive: 1 | ||
--- !u!4 &5607713704072404417 | ||
Transform: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 5607713704072404419} | ||
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 &-2811934882097957570 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 5607713704072404419} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: 0f12c18f4e3ffe8db8e000322288d324, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
config: {fileID: 4900000, guid: 329a3f95713299bb5b816d6489f5eec8, type: 3} | ||
--- !u!114 &-5097301488528543352 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 5607713704072404419} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: 9866f68d17542664b8a43c539c1ef4cf, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
poseLandmarksPrefab: {fileID: 7166525400038315749, guid: 69cf28587972333cca1eb4c1a1ec7e6d, | ||
type: 3} | ||
faceLandmarksPrefab: {fileID: 2250723881323860951, guid: 570a388dca04100b8b491a9bc4ef1d51, | ||
type: 3} | ||
handLandmarksPrefab: {fileID: 3100741085041498678, guid: 4eb3a6d7cfea73afdb656b7166ae1a8d, | ||
type: 3} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
# 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 OfficialDemoDesktopCPU's config file (Copied from mediapipe/graphs/hand_tracking/hand_tracking_desktop_live.pbtxt). | ||
# | ||
# CHANGES: | ||
# - Add FlowLimiterCalculator | ||
# - Add ImageTransformationCalculator and rotate the input | ||
# - Use SidePacket instead of ConstantSidePacketCalculator | ||
|
||
# Tracks and renders pose + hands + face landmarks. | ||
|
||
# ImageFrame | ||
input_stream: "input_video" | ||
|
||
output_stream: "pose_landmarks" | ||
output_stream: "pose_roi" | ||
output_stream: "pose_detection" | ||
output_stream: "face_landmarks" | ||
output_stream: "left_hand_landmarks" | ||
output_stream: "right_hand_landmarks" | ||
|
||
output_stream: "pose_landmarks_presence" | ||
output_stream: "pose_roi_presence" | ||
output_stream: "pose_detection_presence" | ||
output_stream: "face_landmarks_presence" | ||
output_stream: "left_hand_landmarks_presence" | ||
output_stream: "right_hand_landmarks_presence" | ||
|
||
# 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:pose_landmarks_presence" | ||
input_stream_info: { | ||
tag_index: "FINISHED" | ||
back_edge: true | ||
} | ||
output_stream: "throttled_input_video" | ||
node_options: { | ||
[type.googleapis.com/mediapipe.FlowLimiterCalculatorOptions] { | ||
max_in_flight: 1 | ||
max_in_queue: 1 | ||
# Timeout is disabled (set to 0) as first frame processing can take more | ||
# than 1 second. | ||
in_flight_timeout: 0 | ||
} | ||
} | ||
} | ||
|
||
node: { | ||
calculator: "ImageFrameToGpuBufferCalculator" | ||
input_stream: "throttled_input_video" | ||
output_stream: "throttled_input_video_gpu" | ||
} | ||
|
||
# Flip vertically because the input image is aligned from top-left to bottom-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 | ||
} | ||
} | ||
} | ||
|
||
node { | ||
calculator: "ConstantSidePacketCalculator" | ||
output_side_packet: "PACKET:0:upper_body_only" | ||
output_side_packet: "PACKET:1:smooth_landmarks" | ||
node_options: { | ||
[type.googleapis.com/mediapipe.ConstantSidePacketCalculatorOptions]: { | ||
packet { bool_value: false } | ||
packet { bool_value: true } | ||
} | ||
} | ||
} | ||
|
||
node { | ||
calculator: "HolisticLandmarkGpu" | ||
input_stream: "IMAGE:transformed_input_video" | ||
input_side_packet: "UPPER_BODY_ONLY:upper_body_only" | ||
input_side_packet: "SMOOTH_LANDMARKS:smooth_landmarks" | ||
output_stream: "POSE_LANDMARKS:pose_landmarks" | ||
output_stream: "POSE_ROI:pose_roi" | ||
output_stream: "POSE_DETECTION:pose_detection" | ||
output_stream: "FACE_LANDMARKS:face_landmarks" | ||
output_stream: "LEFT_HAND_LANDMARKS:left_hand_landmarks" | ||
output_stream: "RIGHT_HAND_LANDMARKS:right_hand_landmarks" | ||
} | ||
|
||
node { | ||
calculator: "PacketPresenceCalculator" | ||
input_stream: "PACKET:pose_landmarks" | ||
output_stream: "PRESENCE:pose_landmarks_presence" | ||
} | ||
|
||
node { | ||
calculator: "PacketPresenceCalculator" | ||
input_stream: "PACKET:pose_roi" | ||
output_stream: "PRESENCE:pose_roi_presence" | ||
} | ||
|
||
node { | ||
calculator: "PacketPresenceCalculator" | ||
input_stream: "PACKET:pose_detection" | ||
output_stream: "PRESENCE:pose_detection_presence" | ||
} | ||
|
||
node { | ||
calculator: "PacketPresenceCalculator" | ||
input_stream: "PACKET:face_landmarks" | ||
output_stream: "PRESENCE:face_landmarks_presence" | ||
} | ||
|
||
node { | ||
calculator: "PacketPresenceCalculator" | ||
input_stream: "PACKET:left_hand_landmarks" | ||
output_stream: "PRESENCE:left_hand_landmarks_presence" | ||
} | ||
|
||
node { | ||
calculator: "PacketPresenceCalculator" | ||
input_stream: "PACKET:right_hand_landmarks" | ||
output_stream: "PRESENCE:right_hand_landmarks_presence" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Mediapipe; | ||
using UnityEngine; | ||
|
||
public class HolisticAnnotationController : AnnotationController { | ||
[SerializeField] GameObject poseLandmarksPrefab = null; | ||
[SerializeField] GameObject faceLandmarksPrefab = null; | ||
[SerializeField] GameObject handLandmarksPrefab = null; | ||
|
||
private GameObject poseLandmarksAnnotation; | ||
private GameObject faceLandmarksAnnotation; | ||
private GameObject leftHandLandmarksAnnotation; | ||
private GameObject rightHandLandmarksAnnotation; | ||
|
||
void Awake() { | ||
poseLandmarksAnnotation = Instantiate(poseLandmarksPrefab); | ||
faceLandmarksAnnotation = Instantiate(faceLandmarksPrefab); | ||
leftHandLandmarksAnnotation = Instantiate(handLandmarksPrefab); | ||
rightHandLandmarksAnnotation = Instantiate(handLandmarksPrefab); | ||
} | ||
|
||
void OnDestroy() { | ||
Destroy(poseLandmarksAnnotation); | ||
Destroy(faceLandmarksAnnotation); | ||
Destroy(leftHandLandmarksAnnotation); | ||
Destroy(rightHandLandmarksAnnotation); | ||
} | ||
|
||
public override void Clear() { | ||
poseLandmarksAnnotation.GetComponent<FullBodyPoseLandmarkListAnnotationController>().Clear(); | ||
faceLandmarksAnnotation.GetComponent<FaceLandmarkListAnnotationController>().Clear(); | ||
leftHandLandmarksAnnotation.GetComponent<HandLandmarkListAnnotationController>().Clear(); | ||
rightHandLandmarksAnnotation.GetComponent<HandLandmarkListAnnotationController>().Clear(); | ||
} | ||
|
||
public void Draw(Transform screenTransform, NormalizedLandmarkList poseLandmarks, NormalizedLandmarkList faceLandmarks, | ||
NormalizedLandmarkList leftHandLandmarks, NormalizedLandmarkList rightHandLandmarks, bool isFlipped = false) | ||
{ | ||
poseLandmarksAnnotation.GetComponent<FullBodyPoseLandmarkListAnnotationController>().Draw(screenTransform, poseLandmarks, isFlipped); | ||
faceLandmarksAnnotation.GetComponent<FaceLandmarkListAnnotationController>().Draw(screenTransform, faceLandmarks, isFlipped); | ||
leftHandLandmarksAnnotation.GetComponent<HandLandmarkListAnnotationController>().Draw(screenTransform, leftHandLandmarks, isFlipped); | ||
rightHandLandmarksAnnotation.GetComponent<HandLandmarkListAnnotationController>().Draw(screenTransform, rightHandLandmarks, isFlipped); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.