From 7dc6638f42daadccf04fa173f17b2da21dd87e03 Mon Sep 17 00:00:00 2001 From: homuler Date: Sat, 30 Jan 2021 14:41:37 +0900 Subject: [PATCH] add IrisLandmarkLeftAndRightFromFaceLandmarks --- mediapipe/modules/iris_landmark/BUILD | 24 ++++++ ...ft_and_right_from_face_landmarks_cpu.pbtxt | 82 +++++++++++++++++++ ...ft_and_right_from_face_landmarks_gpu.pbtxt | 81 ++++++++++++++++++ 3 files changed, 187 insertions(+) create mode 100644 mediapipe/modules/iris_landmark/iris_landmark_left_and_right_from_face_landmarks_cpu.pbtxt create mode 100644 mediapipe/modules/iris_landmark/iris_landmark_left_and_right_from_face_landmarks_gpu.pbtxt diff --git a/mediapipe/modules/iris_landmark/BUILD b/mediapipe/modules/iris_landmark/BUILD index e16a79b87..9f7eea1c3 100644 --- a/mediapipe/modules/iris_landmark/BUILD +++ b/mediapipe/modules/iris_landmark/BUILD @@ -72,6 +72,18 @@ mediapipe_simple_subgraph( ], ) +mediapipe_simple_subgraph( + name = "iris_landmark_left_and_right_from_face_landmarks_gpu", + graph = "iris_landmark_left_and_right_from_face_landmarks_gpu.pbtxt", + register_as = "IrisLandmarkLeftAndRightFromFaceLandmarksGpu", + deps = [ + ":iris_landmark_left_and_right_gpu", + "//mediapipe/calculators/core:concateneate_normalized_landmark_list_calculator", + "//mediapipe/calculators/core:split_normalized_landmark_list_calculator", + "//mediapipe/graphs/iris_tracking/calculators:update_face_landmarks_calculator", + ], +) + mediapipe_simple_subgraph( name = "iris_landmark_left_and_right_cpu", graph = "iris_landmark_left_and_right_cpu.pbtxt", @@ -85,6 +97,18 @@ mediapipe_simple_subgraph( ], ) +mediapipe_simple_subgraph( + name = "iris_landmark_left_and_right_from_face_landmarks_cpu", + graph = "iris_landmark_left_and_right_from_face_landmarks_cpu.pbtxt", + register_as = "IrisLandmarkLeftAndRightFromFaceLandmarksCpu", + deps = [ + ":iris_landmark_left_and_right_cpu", + "//mediapipe/calculators/core:concateneate_normalized_landmark_list_calculator", + "//mediapipe/calculators/core:split_normalized_landmark_list_calculator", + "//mediapipe/graphs/iris_tracking/calculators:update_face_landmarks_calculator", + ], +) + exports_files( srcs = [ "iris_landmark.tflite", diff --git a/mediapipe/modules/iris_landmark/iris_landmark_left_and_right_from_face_landmarks_cpu.pbtxt b/mediapipe/modules/iris_landmark/iris_landmark_left_and_right_from_face_landmarks_cpu.pbtxt new file mode 100644 index 000000000..47bdf87be --- /dev/null +++ b/mediapipe/modules/iris_landmark/iris_landmark_left_and_right_from_face_landmarks_cpu.pbtxt @@ -0,0 +1,82 @@ +# Detects iris landmarks, eye contour landmarks, and corresponding rect (ROI) from face landmarks. + +type: "IrisLandmarkLeftAndRightFromFaceLandmarksCpu" + +# CPU image. (ImageFrame) +input_stream: "IMAGE:input_video" +# Face landmarks. (NormalizedLandmarkList) +input_stream: "FACE_LANDMARKS:face_landmarks" + +# Refined face landmarks. (NormalizedLandmarkList) +output_stream: "UPDATED_FACE_LANDMARKS:refined_face_landmarks" + +# 71 normalized eye contour landmarks. (NormalizedLandmarkList) +output_stream: "LEFT_EYE_CONTOUR_LANDMARKS:left_eye_contour_landmarks" +# 5 normalized iris landmarks. (NormalizedLandmarkList) +output_stream: "LEFT_EYE_IRIS_LANDMARKS:left_iris_landmarks" +# Region of interest used to do calculations for the left eye. (NormalizedRect) +output_stream: "LEFT_EYE_ROI:left_eye_rect_from_landmarks" + +# 71 normalized eye contour landmarks. (NormalizedLandmarkList) +output_stream: "RIGHT_EYE_CONTOUR_LANDMARKS:right_eye_contour_landmarks" +# 5 normalized iris landmarks. (NormalizedLandmarkList) +output_stream: "RIGHT_EYE_IRIS_LANDMARKS:right_iris_landmarks" +# Region of interest used to do calculations for the right eye. (NormalizedRect) +output_stream: "RIGHT_EYE_ROI:right_eye_rect_from_landmarks" + + +# Gets two landmarks which define left eye boundary. +node { + calculator: "SplitNormalizedLandmarkListCalculator" + input_stream: "face_landmarks" + output_stream: "left_eye_boundary_landmarks" + node_options: { + [type.googleapis.com/mediapipe.SplitVectorCalculatorOptions] { + ranges: { begin: 33 end: 34 } + ranges: { begin: 133 end: 134 } + combine_outputs: true + } + } +} + +# Gets two landmarks which define right eye boundary. +node { + calculator: "SplitNormalizedLandmarkListCalculator" + input_stream: "face_landmarks" + output_stream: "right_eye_boundary_landmarks" + node_options: { + [type.googleapis.com/mediapipe.SplitVectorCalculatorOptions] { + ranges: { begin: 362 end: 363 } + ranges: { begin: 263 end: 264 } + combine_outputs: true + } + } +} + +# Detects iris landmarks, eye contour landmarks, and corresponding rect (ROI). +node { + calculator: "IrisLandmarkLeftAndRightCpu" + input_stream: "IMAGE:input_video" + input_stream: "LEFT_EYE_BOUNDARY_LANDMARKS:left_eye_boundary_landmarks" + input_stream: "RIGHT_EYE_BOUNDARY_LANDMARKS:right_eye_boundary_landmarks" + output_stream: "LEFT_EYE_CONTOUR_LANDMARKS:left_eye_contour_landmarks" + output_stream: "LEFT_EYE_IRIS_LANDMARKS:left_iris_landmarks" + output_stream: "LEFT_EYE_ROI:left_eye_rect_from_landmarks" + output_stream: "RIGHT_EYE_CONTOUR_LANDMARKS:right_eye_contour_landmarks" + output_stream: "RIGHT_EYE_IRIS_LANDMARKS:right_iris_landmarks" + output_stream: "RIGHT_EYE_ROI:right_eye_rect_from_landmarks" +} + +node { + calculator: "ConcatenateNormalizedLandmarkListCalculator" + input_stream: "left_eye_contour_landmarks" + input_stream: "right_eye_contour_landmarks" + output_stream: "refined_eye_landmarks" +} + +node { + calculator: "UpdateFaceLandmarksCalculator" + input_stream: "NEW_EYE_LANDMARKS:refined_eye_landmarks" + input_stream: "FACE_LANDMARKS:face_landmarks" + output_stream: "UPDATED_FACE_LANDMARKS:refined_face_landmarks" +} diff --git a/mediapipe/modules/iris_landmark/iris_landmark_left_and_right_from_face_landmarks_gpu.pbtxt b/mediapipe/modules/iris_landmark/iris_landmark_left_and_right_from_face_landmarks_gpu.pbtxt new file mode 100644 index 000000000..600c55769 --- /dev/null +++ b/mediapipe/modules/iris_landmark/iris_landmark_left_and_right_from_face_landmarks_gpu.pbtxt @@ -0,0 +1,81 @@ +# Detects iris landmarks, eye contour landmarks, and corresponding rect (ROI) from face landmarks. + +type: "IrisLandmarkLeftAndRightFromFaceLandmarksGpu" + +# GPU image. (GpuBuffer) +input_stream: "IMAGE:input_video" +# Face landmarks. (NormalizedLandmarkList) +input_stream: "FACE_LANDMARKS:face_landmarks" + +# Refined face landmarks. (NormalizedLandmarkList) +output_stream: "UPDATED_FACE_LANDMARKS:refined_face_landmarks" + +# 71 normalized eye contour landmarks. (NormalizedLandmarkList) +output_stream: "LEFT_EYE_CONTOUR_LANDMARKS:left_eye_contour_landmarks" +# 5 normalized iris landmarks. (NormalizedLandmarkList) +output_stream: "LEFT_EYE_IRIS_LANDMARKS:left_iris_landmarks" +# Region of interest used to do calculations for the left eye. (NormalizedRect) +output_stream: "LEFT_EYE_ROI:left_eye_rect_from_landmarks" + +# 71 normalized eye contour landmarks. (NormalizedLandmarkList) +output_stream: "RIGHT_EYE_CONTOUR_LANDMARKS:right_eye_contour_landmarks" +# 5 normalized iris landmarks. (NormalizedLandmarkList) +output_stream: "RIGHT_EYE_IRIS_LANDMARKS:right_iris_landmarks" +# Region of interest used to do calculations for the right eye. (NormalizedRect) +output_stream: "RIGHT_EYE_ROI:right_eye_rect_from_landmarks" + +# Gets two landmarks which define left eye boundary. +node { + calculator: "SplitNormalizedLandmarkListCalculator" + input_stream: "face_landmarks" + output_stream: "left_eye_boundary_landmarks" + node_options: { + [type.googleapis.com/mediapipe.SplitVectorCalculatorOptions] { + ranges: { begin: 33 end: 34 } + ranges: { begin: 133 end: 134 } + combine_outputs: true + } + } +} + +# Gets two landmarks which define right eye boundary. +node { + calculator: "SplitNormalizedLandmarkListCalculator" + input_stream: "face_landmarks" + output_stream: "right_eye_boundary_landmarks" + node_options: { + [type.googleapis.com/mediapipe.SplitVectorCalculatorOptions] { + ranges: { begin: 362 end: 363 } + ranges: { begin: 263 end: 264 } + combine_outputs: true + } + } +} + +# Detects iris landmarks, eye contour landmarks, and corresponding rect (ROI). +node { + calculator: "IrisLandmarkLeftAndRightGpu" + input_stream: "IMAGE:input_image" + input_stream: "LEFT_EYE_BOUNDARY_LANDMARKS:left_eye_boundary_landmarks" + input_stream: "RIGHT_EYE_BOUNDARY_LANDMARKS:right_eye_boundary_landmarks" + output_stream: "LEFT_EYE_CONTOUR_LANDMARKS:left_eye_contour_landmarks" + output_stream: "LEFT_EYE_IRIS_LANDMARKS:left_iris_landmarks" + output_stream: "LEFT_EYE_ROI:left_eye_rect_from_landmarks" + output_stream: "RIGHT_EYE_CONTOUR_LANDMARKS:right_eye_contour_landmarks" + output_stream: "RIGHT_EYE_IRIS_LANDMARKS:right_iris_landmarks" + output_stream: "RIGHT_EYE_ROI:right_eye_rect_from_landmarks" +} + +node { + calculator: "ConcatenateNormalizedLandmarkListCalculator" + input_stream: "left_eye_contour_landmarks" + input_stream: "right_eye_contour_landmarks" + output_stream: "refined_eye_landmarks" +} + +node { + calculator: "UpdateFaceLandmarksCalculator" + input_stream: "NEW_EYE_LANDMARKS:refined_eye_landmarks" + input_stream: "FACE_LANDMARKS:face_landmarks" + output_stream: "UPDATED_FACE_LANDMARKS:refined_face_landmarks" +}