# Converts hand-related pose landmarks to hand re-crop ROI.

type: "HandLandmarksFromPoseToRecropRoi"

# Hand-related pose landmarks in [wrist, pinky, index] order.
# (NormalizedLandmarkList)
input_stream: "HAND_LANDMARKS_FROM_POSE:hand_landmarks_from_pose"
# Image size (width & height). (std::pair<int, int>)
input_stream: "IMAGE_SIZE:image_size"

# ROI to be used for re-crop prediction. (NormalizedRect)
output_stream: "ROI:roi"

# Converts hand-related pose landmarks to a detection that tightly encloses all
# of them.
node {
  calculator: "LandmarksToDetectionCalculator"
  input_stream: "NORM_LANDMARKS:hand_landmarks_from_pose"
  output_stream: "DETECTION:hand_detection_from_pose"
}

# Converts hand detection to a normalized hand rectangle.
node {
  calculator: "HandDetectionsFromPoseToRectsCalculator"
  input_stream: "DETECTION:hand_detection_from_pose"
  input_stream: "IMAGE_SIZE:image_size"
  output_stream: "NORM_RECT:hand_roi_from_pose"
}

# Expands the palm rectangle so that it becomes big enough for hand re-crop
# model to localize it accurately.
node {
  calculator: "RectTransformationCalculator"
  input_stream: "NORM_RECT:hand_roi_from_pose"
  input_stream: "IMAGE_SIZE:image_size"
  output_stream: "roi"
  options: {
    [mediapipe.RectTransformationCalculatorOptions.ext] {
      scale_x: 2.7
      scale_y: 2.7
      shift_y: -0.1
      square_long: true
    }
  }
}
