# MediaPipe pose landmarks rendering subgraph.

type: "PoseRendererGpu"

# GPU image. (GpuBuffer)
input_stream: "IMAGE:input_image"
# Pose landmarks. (NormalizedLandmarkList)
input_stream: "LANDMARKS:pose_landmarks"
# Segmentation mask. (GpuBuffer in RGBA, with the same mask values in R and A)
input_stream: "SEGMENTATION_MASK:segmentation_mask"
# Region of interest calculated based on landmarks. (NormalizedRect)
input_stream: "ROI:roi"
# Detected pose. (Detection)
input_stream: "DETECTION:detection"

# GPU image with rendered data. (GpuBuffer)
output_stream: "IMAGE:output_image"

node {
  calculator: "ImagePropertiesCalculator"
  input_stream: "IMAGE_GPU:input_image"
  output_stream: "SIZE:image_size"
}

# Converts detections to drawing primitives for annotation overlay.
node {
  calculator: "DetectionsToRenderDataCalculator"
  input_stream: "DETECTION:detection"
  output_stream: "RENDER_DATA:detection_render_data"
  node_options: {
    [type.googleapis.com/mediapipe.DetectionsToRenderDataCalculatorOptions] {
      thickness: 4.0
      color { r: 0 g: 255 b: 0 }
    }
  }
}

# Computes render data for landmarks.
node {
  calculator: "PoseLandmarksToRenderData"
  input_stream: "LANDMARKS:pose_landmarks"
  input_stream: "ROI:roi"
  input_stream: "IMAGE_SIZE:image_size"
  output_stream: "RENDER_DATA:landmarks_render_data"
}

# Converts normalized rects to drawing primitives for annotation overlay.
node {
  calculator: "RectToRenderDataCalculator"
  input_stream: "NORM_RECT:roi"
  output_stream: "RENDER_DATA:roi_render_data"
  node_options: {
    [type.googleapis.com/mediapipe.RectToRenderDataCalculatorOptions] {
      filled: false
      color { r: 255 g: 0 b: 0 }
      thickness: 4.0
    }
  }
}

# Colors the segmentation mask with the color specified in the option.
node {
  calculator: "RecolorCalculator"
  input_stream: "IMAGE_GPU:input_image"
  input_stream: "MASK_GPU:segmentation_mask"
  output_stream: "IMAGE_GPU:segmented_image"
  node_options: {
    [type.googleapis.com/mediapipe.RecolorCalculatorOptions] {
      color { r: 0 g: 0 b: 255 }
      mask_channel: RED
      invert_mask: true
      adjust_with_luminance: false
    }
  }
}

# Draws annotations and overlays them on top of the input images.
node {
  calculator: "AnnotationOverlayCalculator"
  input_stream: "IMAGE_GPU:segmented_image"
  input_stream: "detection_render_data"
  input_stream: "VECTOR:landmarks_render_data"
  input_stream: "roi_render_data"
  output_stream: "IMAGE_GPU:output_image"
}
