# MediaPipe graph to calculate pose region of interest (ROI) from a detection
# provided by "PoseDetectionCpu" or "PoseDetectionGpu"
#
# NOTE: this graph is subject to change and should not be used directly.

type: "PoseDetectionToRoi"

# Pose detection. (Detection)
input_stream: "DETECTION:detection"
# Frame size (width and height). (std::pair<int, int>)
input_stream: "IMAGE_SIZE:image_size"

# ROI according to the first detection of input detections. (NormalizedRect)
output_stream: "ROI:roi"

# Converts pose detection into a rectangle based on center and scale alignment
# points.
node {
  calculator: "AlignmentPointsRectsCalculator"
  input_stream: "DETECTION:detection"
  input_stream: "IMAGE_SIZE:image_size"
  output_stream: "NORM_RECT:raw_roi"
  options: {
    [mediapipe.DetectionsToRectsCalculatorOptions.ext] {
      rotation_vector_start_keypoint_index: 0
      rotation_vector_end_keypoint_index: 1
      rotation_vector_target_angle_degrees: 90
    }
  }
}

# Expands pose rect with marging used during training.
node {
  calculator: "RectTransformationCalculator"
  input_stream: "NORM_RECT:raw_roi"
  input_stream: "IMAGE_SIZE:image_size"
  output_stream: "roi"
  options: {
    [mediapipe.RectTransformationCalculatorOptions.ext] {
      scale_x: 1.25
      scale_y: 1.25
      square_long: true
    }
  }
}
