# MediaPipe iris tracking rendering subgraph.

type: "IrisAndDepthRendererCpu"

input_stream: "IMAGE:input_image"
input_stream: "DETECTIONS:detections"
input_stream: "FACE_LANDMARKS:face_landmarks"
input_stream: "EYE_LANDMARKS_LEFT:all_left_eye_contour_landmarks"
input_stream: "EYE_LANDMARKS_RIGHT:all_right_eye_contour_landmarks"
input_stream: "IRIS_LANDMARKS_LEFT:left_iris_landmarks"
input_stream: "IRIS_LANDMARKS_RIGHT:right_iris_landmarks"
input_stream: "NORM_RECT:rect"
input_stream: "LEFT_EYE_RECT:left_eye_rect_from_landmarks"
input_stream: "RIGHT_EYE_RECT:right_eye_rect_from_landmarks"
input_side_packet: "IMAGE_FILE_PROPERTIES:image_file_properties"
output_stream: "IRIS_LANDMARKS:iris_landmarks"
output_stream: "IMAGE:output_image"
output_stream: "LEFT_IRIS_DEPTH_MM:left_iris_depth_mm"
output_stream: "RIGHT_IRIS_DEPTH_MM:right_iris_depth_mm"

node {
  calculator: "SplitNormalizedLandmarkListCalculator"
  input_stream: "all_left_eye_contour_landmarks"
  output_stream: "left_eye_contour_landmarks"
  node_options: {
    [type.googleapis.com/mediapipe.SplitVectorCalculatorOptions] {
      ranges: { begin: 0 end: 15 }
    }
  }
}

node {
  calculator: "SplitNormalizedLandmarkListCalculator"
  input_stream: "all_right_eye_contour_landmarks"
  output_stream: "right_eye_contour_landmarks"
  node_options: {
    [type.googleapis.com/mediapipe.SplitVectorCalculatorOptions] {
      ranges: { begin: 0 end: 15 }
    }
  }
}

# Concatenate iris landmarks from both eyes.
node {
  calculator: "ConcatenateNormalizedLandmarkListCalculator"
  input_stream: "left_iris_landmarks"
  input_stream: "right_iris_landmarks"
  output_stream: "iris_landmarks"
}

# Converts landmarks to drawing primitives for annotation overlay.
node {
  calculator: "FaceLandmarksToRenderDataCalculator"
  input_stream: "NORM_LANDMARKS:face_landmarks"
  output_stream: "RENDER_DATA:face_landmarks_render_data"
  node_options: {
    [type.googleapis.com/mediapipe.LandmarksToRenderDataCalculatorOptions] {
      landmark_color { r: 150 g: 0 b: 0 }
      connection_color { r: 0 g: 150 b: 0 }
      thickness: 2
      visualize_landmark_depth: false
    }
  }
}

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

# Maps detection label IDs to the corresponding label text ("Face").
node {
  calculator: "DetectionLabelIdToTextCalculator"
  input_stream: "detections"
  output_stream: "labeled_detections"
  node_options: {
    [type.googleapis.com/mediapipe.DetectionLabelIdToTextCalculatorOptions] {
      label: "Face"
    }
  }
}

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

# Converts landmarks to drawing primitives for annotation overlay.
node {
  calculator: "LandmarksToRenderDataCalculator"
  input_stream: "NORM_LANDMARKS:left_eye_contour_landmarks"
  output_stream: "RENDER_DATA:left_eye_contour_landmarks_render_data"
  node_options: {
    [type.googleapis.com/mediapipe.LandmarksToRenderDataCalculatorOptions] {
      landmark_connections: 0
      landmark_connections: 1
      landmark_connections: 1
      landmark_connections: 2
      landmark_connections: 2
      landmark_connections: 3
      landmark_connections: 3
      landmark_connections: 4
      landmark_connections: 4
      landmark_connections: 5
      landmark_connections: 5
      landmark_connections: 6
      landmark_connections: 6
      landmark_connections: 7
      landmark_connections: 7
      landmark_connections: 8
      landmark_connections: 9
      landmark_connections: 10
      landmark_connections: 10
      landmark_connections: 11
      landmark_connections: 11
      landmark_connections: 12
      landmark_connections: 12
      landmark_connections: 13
      landmark_connections: 13
      landmark_connections: 14
      landmark_connections: 0
      landmark_connections: 9
      landmark_connections: 8
      landmark_connections: 14
      landmark_color { r: 255 g: 0 b: 0 }
      connection_color { r: 255 g: 0 b: 0 }
      visualize_landmark_depth: false
      thickness: 1.0
    }
  }
}

# Converts landmarks to drawing primitives for annotation overlay.
node {
  calculator: "LandmarksToRenderDataCalculator"
  input_stream: "NORM_LANDMARKS:right_eye_contour_landmarks"
  output_stream: "RENDER_DATA:right_eye_contour_landmarks_render_data"
  node_options: {
    [type.googleapis.com/mediapipe.LandmarksToRenderDataCalculatorOptions] {
      landmark_connections: 0
      landmark_connections: 1
      landmark_connections: 1
      landmark_connections: 2
      landmark_connections: 2
      landmark_connections: 3
      landmark_connections: 3
      landmark_connections: 4
      landmark_connections: 4
      landmark_connections: 5
      landmark_connections: 5
      landmark_connections: 6
      landmark_connections: 6
      landmark_connections: 7
      landmark_connections: 7
      landmark_connections: 8
      landmark_connections: 9
      landmark_connections: 10
      landmark_connections: 10
      landmark_connections: 11
      landmark_connections: 11
      landmark_connections: 12
      landmark_connections: 12
      landmark_connections: 13
      landmark_connections: 13
      landmark_connections: 14
      landmark_connections: 0
      landmark_connections: 9
      landmark_connections: 8
      landmark_connections: 14
      landmark_color { r: 255 g: 0 b: 0 }
      connection_color { r: 255 g: 0 b: 0 }
      visualize_landmark_depth: false
      thickness: 1.0
    }
  }
}

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

node {
  calculator: "RectToRenderDataCalculator"
  input_stream: "NORM_RECT:right_eye_rect_from_landmarks"
  output_stream: "RENDER_DATA:right_eye_rect_render_data"
  node_options: {
    [type.googleapis.com/mediapipe.RectToRenderDataCalculatorOptions] {
      filled: false
      color { r: 255 g: 0 b: 0 }
      thickness: 4.0
    }
  }
}

node {
  calculator: "RectToRenderDataCalculator"
  input_stream: "NORM_RECT:left_eye_rect_from_landmarks"
  output_stream: "RENDER_DATA:left_eye_rect_render_data"
  node_options: {
    [type.googleapis.com/mediapipe.RectToRenderDataCalculatorOptions] {
      filled: false
      color { r: 255 g: 0 b: 0 }
      thickness: 4.0
    }
  }
}

node {
  calculator: "IrisToDepthCalculator"
  input_stream: "IRIS:iris_landmarks"
  input_stream: "IMAGE_SIZE:image_size"
  input_side_packet: "IMAGE_FILE_PROPERTIES:image_file_properties"
  output_stream: "LEFT_IRIS_DEPTH_MM:left_iris_depth_mm"
  output_stream: "RIGHT_IRIS_DEPTH_MM:right_iris_depth_mm"
}

node {
  calculator: "IrisToRenderDataCalculator"
  input_stream: "IRIS:iris_landmarks"
  input_stream: "IMAGE_SIZE:image_size"
  input_stream: "LEFT_IRIS_DEPTH_MM:left_iris_depth_mm"
  input_stream: "RIGHT_IRIS_DEPTH_MM:right_iris_depth_mm"
  output_stream: "RENDER_DATA:iris_render_data"
  node_options: {
    [type.googleapis.com/mediapipe.IrisToRenderDataCalculatorOptions] {
      oval_color { r: 0 g: 0 b: 255 }
      landmark_color { r: 0 g: 255 b: 0 }
      oval_thickness: 2.0
      landmark_thickness: 1.0
      font_height_px: 50
      horizontal_offset_px: 200
      vertical_offset_px: 200
      location: TOP_LEFT
    }
  }
}

# Draws annotations and overlays them on top of the input images.
node {
  calculator: "AnnotationOverlayCalculator"
  input_stream: "IMAGE:input_image"
  input_stream: "detection_render_data"
  input_stream: "face_landmarks_render_data"
  input_stream: "right_eye_contour_landmarks_render_data"
  input_stream: "left_eye_contour_landmarks_render_data"
  input_stream: "iris_render_data"
  output_stream: "IMAGE:output_image"
}
