73 lines
2.9 KiB
Protocol Buffer Text Format
73 lines
2.9 KiB
Protocol Buffer Text Format
# MediaPipe graph to detect/predict hand landmarks on GPU.
|
|
#
|
|
# The procedure is done in two steps:
|
|
# - locate palms/hands
|
|
# - detect landmarks for each palm/hand.
|
|
# This graph tries to skip palm detection as much as possible by reusing
|
|
# previously detected/predicted landmarks for new images.
|
|
|
|
type: "HandLandmarkTrackingGpuImage"
|
|
|
|
# Input image. (Image)
|
|
input_stream: "IMAGE:image"
|
|
|
|
# Max number of hands to detect/track. (int)
|
|
input_side_packet: "NUM_HANDS:num_hands"
|
|
|
|
# Collection of detected/predicted hands, each represented as a list of
|
|
# landmarks. (std::vector<NormalizedLandmarkList>)
|
|
# NOTE: there will not be an output packet in the LANDMARKS stream for this
|
|
# particular timestamp if none of hands detected. However, the MediaPipe
|
|
# framework will internally inform the downstream calculators of the absence of
|
|
# this packet so that they don't wait for it unnecessarily.
|
|
output_stream: "LANDMARKS:multi_hand_landmarks"
|
|
# Collection of handedness of the detected hands (i.e. is hand left or right),
|
|
# each represented as a Classification proto.
|
|
# Note that handedness is determined assuming the input image is mirrored,
|
|
# i.e., taken with a front-facing/selfie camera with images flipped
|
|
# horizontally.
|
|
output_stream: "HANDEDNESS:multi_handedness"
|
|
|
|
# The original input image. (Image)
|
|
output_stream: "IMAGE:image"
|
|
# Extra outputs (for debugging, for instance).
|
|
# Detected palms. (std::vector<Detection>)
|
|
output_stream: "PALM_DETECTIONS:palm_detections"
|
|
# Regions of interest calculated based on landmarks.
|
|
# (std::vector<NormalizedRect>)
|
|
output_stream: "HAND_ROIS_FROM_LANDMARKS:hand_rects"
|
|
# Regions of interest calculated based on palm detections.
|
|
# (std::vector<NormalizedRect>)
|
|
output_stream: "HAND_ROIS_FROM_PALM_DETECTIONS:hand_rects_from_palm_detections"
|
|
|
|
# Converts Image to GpuBuffer for HandLandmarkTrackingGpu to consume.
|
|
node {
|
|
calculator: "FromImageCalculator"
|
|
input_stream: "IMAGE:image"
|
|
output_stream: "IMAGE_GPU:raw_gpu_buffer"
|
|
output_stream: "SOURCE_ON_GPU:is_gpu_image"
|
|
}
|
|
|
|
# TODO: Remove the extra flipping once adopting MlImage.
|
|
# If the source images are on gpu, flip the data vertically before sending them
|
|
# into HandLandmarkTrackingGpu. This maybe needed because OpenGL represents
|
|
# images assuming the image origin is at the bottom-left corner, whereas
|
|
# MediaPipe in general assumes the image origin is at the top-left corner.
|
|
node: {
|
|
calculator: "ImageTransformationCalculator"
|
|
input_stream: "IMAGE_GPU:raw_gpu_buffer"
|
|
input_stream: "FLIP_VERTICALLY:is_gpu_image"
|
|
output_stream: "IMAGE_GPU:gpu_buffer"
|
|
}
|
|
|
|
node {
|
|
calculator: "HandLandmarkTrackingGpu"
|
|
input_stream: "IMAGE:gpu_buffer"
|
|
input_side_packet: "NUM_HANDS:num_hands"
|
|
output_stream: "LANDMARKS:multi_hand_landmarks"
|
|
output_stream: "HANDEDNESS:multi_handedness"
|
|
output_stream: "PALM_DETECTIONS:palm_detections"
|
|
output_stream: "HAND_ROIS_FROM_LANDMARKS:hand_rects"
|
|
output_stream: "HAND_ROIS_FROM_PALM_DETECTIONS:hand_rects_from_palm_detections"
|
|
}
|