add soft eye line
Browse files- app.py +4 -0
- draw_landmarks68.py +3 -3
- mp_constants.py +26 -2
app.py
CHANGED
|
@@ -7,6 +7,7 @@ import os
|
|
| 7 |
import time
|
| 8 |
import mp_box
|
| 9 |
import draw_landmarks68
|
|
|
|
| 10 |
'''
|
| 11 |
Face landmark detection based Face Detection.
|
| 12 |
https://ai.google.dev/edge/mediapipe/solutions/vision/face_landmarker
|
|
@@ -61,6 +62,9 @@ def process_images(image,draw_number,font_scale,text_color_text,dot_size,dot_col
|
|
| 61 |
line_color = picker_color_to_rgba(line_color_text)
|
| 62 |
dot_color = picker_color_to_rgba(dot_color_text)
|
| 63 |
box_color = picker_color_to_rgba(box_color_text)
|
|
|
|
|
|
|
|
|
|
| 64 |
annotated_image,bbox,landmark_points = draw_landmarks68.draw_landmarks_on_image(image,face_landmarker_result,draw_number,font_scale,text_color,
|
| 65 |
dot_size,dot_color,line_size,line_color,
|
| 66 |
box_size,box_color)
|
|
|
|
| 7 |
import time
|
| 8 |
import mp_box
|
| 9 |
import draw_landmarks68
|
| 10 |
+
|
| 11 |
'''
|
| 12 |
Face landmark detection based Face Detection.
|
| 13 |
https://ai.google.dev/edge/mediapipe/solutions/vision/face_landmarker
|
|
|
|
| 62 |
line_color = picker_color_to_rgba(line_color_text)
|
| 63 |
dot_color = picker_color_to_rgba(dot_color_text)
|
| 64 |
box_color = picker_color_to_rgba(box_color_text)
|
| 65 |
+
|
| 66 |
+
image=Image.fromarray(mp_box.draw_landmarks_on_image(face_landmarker_result,image))
|
| 67 |
+
|
| 68 |
annotated_image,bbox,landmark_points = draw_landmarks68.draw_landmarks_on_image(image,face_landmarker_result,draw_number,font_scale,text_color,
|
| 69 |
dot_size,dot_color,line_size,line_color,
|
| 70 |
box_size,box_color)
|
draw_landmarks68.py
CHANGED
|
@@ -51,7 +51,7 @@ def parse_arguments():
|
|
| 51 |
|
| 52 |
|
| 53 |
def draw_landmarks_on_image(rgb_image, detection_result,draw_number,font_scale,text_color,dot_size,dot_color,line_size,line_color,box_size,box_color):
|
| 54 |
-
print(f"dot_size={dot_size},dot_color={dot_color},line_size={line_size},line_color={line_color}")
|
| 55 |
image_width,iamge_height = rgb_image.size
|
| 56 |
face_landmarks_list = detection_result.face_landmarks
|
| 57 |
annotated_image = np.copy(rgb_image)
|
|
@@ -368,7 +368,7 @@ def draw_landmarks_on_image(rgb_image, detection_result,draw_number,font_scale,t
|
|
| 368 |
horizontal_nose_points = get_mean_points([LANDMARK_68_HORIZONTAL_NOSE_32,LANDMARK_68_HORIZONTAL_NOSE_33,LANDMARK_68_HORIZONTAL_NOSE_34,LANDMARK_68_HORIZONTAL_NOSE_35,LANDMARK_68_HORIZONTAL_NOSE_36])
|
| 369 |
plot_points(annotated_image,horizontal_nose_points,False,dot_size,dot_color,line_size,line_color)
|
| 370 |
|
| 371 |
-
right_upper_eye_points = get_divided_points(
|
| 372 |
right_lower_eye_points = get_divided_points(LINE_RIGHT_LOWER_MIXED_EYE,3)
|
| 373 |
#right_eye_points = right_upper_eye_points+right_lower_eye_points # first and last is same as above
|
| 374 |
right_eye_points = right_upper_eye_points+right_lower_eye_points[1:-1]
|
|
@@ -379,7 +379,7 @@ def draw_landmarks_on_image(rgb_image, detection_result,draw_number,font_scale,t
|
|
| 379 |
#draw_lines(LINE_RIGHT_UPPER_OUTER_EYE,(0,255,0))
|
| 380 |
#draw_lines(LINE_RIGHT_UPPER_INNER_EYE,(0,255,0))
|
| 381 |
|
| 382 |
-
left_upper_eye_points = get_divided_points(
|
| 383 |
left_lower_eye_points = get_divided_points(LINE_LEFT_LOWER_MIXED_EYE,3)
|
| 384 |
#left_eye_points = left_upper_eye_points+left_lower_eye_points# first and last is same as above
|
| 385 |
left_eye_points = left_upper_eye_points+left_lower_eye_points[1:-1]
|
|
|
|
| 51 |
|
| 52 |
|
| 53 |
def draw_landmarks_on_image(rgb_image, detection_result,draw_number,font_scale,text_color,dot_size,dot_color,line_size,line_color,box_size,box_color):
|
| 54 |
+
#print(f"dot_size={dot_size},dot_color={dot_color},line_size={line_size},line_color={line_color}")
|
| 55 |
image_width,iamge_height = rgb_image.size
|
| 56 |
face_landmarks_list = detection_result.face_landmarks
|
| 57 |
annotated_image = np.copy(rgb_image)
|
|
|
|
| 368 |
horizontal_nose_points = get_mean_points([LANDMARK_68_HORIZONTAL_NOSE_32,LANDMARK_68_HORIZONTAL_NOSE_33,LANDMARK_68_HORIZONTAL_NOSE_34,LANDMARK_68_HORIZONTAL_NOSE_35,LANDMARK_68_HORIZONTAL_NOSE_36])
|
| 369 |
plot_points(annotated_image,horizontal_nose_points,False,dot_size,dot_color,line_size,line_color)
|
| 370 |
|
| 371 |
+
right_upper_eye_points = get_divided_points(LINE_RIGHT_UPPER_MIXED_EYE2,3)
|
| 372 |
right_lower_eye_points = get_divided_points(LINE_RIGHT_LOWER_MIXED_EYE,3)
|
| 373 |
#right_eye_points = right_upper_eye_points+right_lower_eye_points # first and last is same as above
|
| 374 |
right_eye_points = right_upper_eye_points+right_lower_eye_points[1:-1]
|
|
|
|
| 379 |
#draw_lines(LINE_RIGHT_UPPER_OUTER_EYE,(0,255,0))
|
| 380 |
#draw_lines(LINE_RIGHT_UPPER_INNER_EYE,(0,255,0))
|
| 381 |
|
| 382 |
+
left_upper_eye_points = get_divided_points(LINE_LEFT_UPPER_MIXED_EYE2,3)
|
| 383 |
left_lower_eye_points = get_divided_points(LINE_LEFT_LOWER_MIXED_EYE,3)
|
| 384 |
#left_eye_points = left_upper_eye_points+left_lower_eye_points# first and last is same as above
|
| 385 |
left_eye_points = left_upper_eye_points+left_lower_eye_points[1:-1]
|
mp_constants.py
CHANGED
|
@@ -164,7 +164,18 @@ LINE_RIGHT_UPPER_OUTER_EYE=[POINT_RIGHT_UPPER_OUTER_EYE_1,POINT_RIGHT_UPPER_OUTE
|
|
| 164 |
|
| 165 |
LINE_RIGHT_UPPER_MIXED_EYE =[#firs eye1 and eye2 is intesionaly for moveup
|
| 166 |
[POINT_RIGHT_UPPER_INNER_EYE_1,POINT_RIGHT_UPPER_OUTER_EYE_2], [POINT_RIGHT_UPPER_INNER_EYE_2,POINT_RIGHT_UPPER_OUTER_EYE_2], [POINT_RIGHT_UPPER_INNER_EYE_3,POINT_RIGHT_UPPER_OUTER_EYE_3], [POINT_RIGHT_UPPER_INNER_EYE_4,POINT_RIGHT_UPPER_OUTER_EYE_4], [POINT_RIGHT_UPPER_INNER_EYE_5,POINT_RIGHT_UPPER_OUTER_EYE_5], [POINT_RIGHT_UPPER_INNER_EYE_6,POINT_RIGHT_UPPER_OUTER_EYE_6]
|
| 167 |
-
,[POINT_RIGHT_UPPER_INNER_EYE_8],[POINT_RIGHT_UPPER_INNER_EYE_8,POINT_RIGHT_UPPER_INNER_EYE_9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
]
|
| 169 |
|
| 170 |
POINT_RIGHT_LOWER_OUTER_EYE_1 = 112
|
|
@@ -196,6 +207,7 @@ POINT_LEFT_UPPER_INNER_EYE_8 = 466
|
|
| 196 |
POINT_LEFT_UPPER_INNER_EYE_9 = 263
|
| 197 |
|
| 198 |
LINE_LEFT_UPPER_INNER_EYE=[POINT_LEFT_UPPER_INNER_EYE_1,POINT_LEFT_UPPER_INNER_EYE_2,POINT_LEFT_UPPER_INNER_EYE_3,POINT_LEFT_UPPER_INNER_EYE_4,POINT_LEFT_UPPER_INNER_EYE_5,POINT_LEFT_UPPER_INNER_EYE_6,POINT_LEFT_UPPER_INNER_EYE_7,POINT_LEFT_UPPER_INNER_EYE_8,POINT_LEFT_UPPER_INNER_EYE_9]
|
|
|
|
| 199 |
|
| 200 |
|
| 201 |
|
|
@@ -237,9 +249,21 @@ LINE_LEFT_LOWER_OUTER_EYE=[POINT_LEFT_UPPER_OUTER_EYE_9,POINT_LEFT_LOWER_OUTER_E
|
|
| 237 |
|
| 238 |
LINE_LEFT_UPPER_MIXED_EYE =[#firs eye1 and eye2 is intesionaly for moveup
|
| 239 |
[POINT_LEFT_UPPER_INNER_EYE_1,POINT_LEFT_UPPER_INNER_EYE_2,POINT_LEFT_LOWER_INNER_EYE_7],
|
| 240 |
-
[POINT_LEFT_UPPER_INNER_EYE_2,POINT_LEFT_UPPER_OUTER_EYE_2], [POINT_LEFT_UPPER_INNER_EYE_3,POINT_LEFT_UPPER_OUTER_EYE_3], [POINT_LEFT_UPPER_INNER_EYE_4,POINT_LEFT_UPPER_OUTER_EYE_4], [POINT_LEFT_UPPER_INNER_EYE_5,POINT_LEFT_UPPER_OUTER_EYE_5], [POINT_LEFT_UPPER_INNER_EYE_6,POINT_LEFT_UPPER_OUTER_EYE_6]
|
| 241 |
,[POINT_LEFT_UPPER_INNER_EYE_8],[POINT_LEFT_UPPER_OUTER_EYE_8,POINT_LEFT_UPPER_INNER_EYE_9]
|
| 242 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
LINE_LEFT_LOWER_MIXED_EYE =[
|
| 244 |
[POINT_LEFT_UPPER_OUTER_EYE_8,POINT_LEFT_UPPER_INNER_EYE_9]
|
| 245 |
,[POINT_LEFT_LOWER_INNER_EYE_2]
|
|
|
|
| 164 |
|
| 165 |
LINE_RIGHT_UPPER_MIXED_EYE =[#firs eye1 and eye2 is intesionaly for moveup
|
| 166 |
[POINT_RIGHT_UPPER_INNER_EYE_1,POINT_RIGHT_UPPER_OUTER_EYE_2], [POINT_RIGHT_UPPER_INNER_EYE_2,POINT_RIGHT_UPPER_OUTER_EYE_2], [POINT_RIGHT_UPPER_INNER_EYE_3,POINT_RIGHT_UPPER_OUTER_EYE_3], [POINT_RIGHT_UPPER_INNER_EYE_4,POINT_RIGHT_UPPER_OUTER_EYE_4], [POINT_RIGHT_UPPER_INNER_EYE_5,POINT_RIGHT_UPPER_OUTER_EYE_5], [POINT_RIGHT_UPPER_INNER_EYE_6,POINT_RIGHT_UPPER_OUTER_EYE_6]
|
| 167 |
+
,[POINT_RIGHT_UPPER_INNER_EYE_8],[POINT_RIGHT_UPPER_INNER_EYE_8,POINT_RIGHT_UPPER_INNER_EYE_9] #I'm not sure need this one or not POINT_RIGHT_LOWER_INNER_EYE_1
|
| 168 |
+
]
|
| 169 |
+
|
| 170 |
+
LINE_RIGHT_UPPER_MIXED_EYE2 =[#firs eye1 and eye2 is intesionaly for moveup
|
| 171 |
+
[POINT_RIGHT_UPPER_INNER_EYE_1,POINT_RIGHT_UPPER_INNER_EYE_1,POINT_RIGHT_UPPER_OUTER_EYE_2],
|
| 172 |
+
[POINT_RIGHT_UPPER_INNER_EYE_2,POINT_RIGHT_UPPER_INNER_EYE_2,POINT_RIGHT_UPPER_OUTER_EYE_2],
|
| 173 |
+
[POINT_RIGHT_UPPER_INNER_EYE_3,POINT_RIGHT_UPPER_INNER_EYE_3,POINT_RIGHT_UPPER_OUTER_EYE_3],
|
| 174 |
+
[POINT_RIGHT_UPPER_INNER_EYE_4,POINT_RIGHT_UPPER_INNER_EYE_4,POINT_RIGHT_UPPER_OUTER_EYE_4],
|
| 175 |
+
[POINT_RIGHT_UPPER_INNER_EYE_5,POINT_RIGHT_UPPER_INNER_EYE_5,POINT_RIGHT_UPPER_OUTER_EYE_5],
|
| 176 |
+
[POINT_RIGHT_UPPER_INNER_EYE_6,POINT_RIGHT_UPPER_INNER_EYE_6,POINT_RIGHT_UPPER_OUTER_EYE_6]
|
| 177 |
+
,[POINT_RIGHT_UPPER_INNER_EYE_8],
|
| 178 |
+
[POINT_RIGHT_UPPER_INNER_EYE_8,POINT_RIGHT_UPPER_INNER_EYE_9] #I'm not sure need this one or not POINT_RIGHT_LOWER_INNER_EYE_1
|
| 179 |
]
|
| 180 |
|
| 181 |
POINT_RIGHT_LOWER_OUTER_EYE_1 = 112
|
|
|
|
| 207 |
POINT_LEFT_UPPER_INNER_EYE_9 = 263
|
| 208 |
|
| 209 |
LINE_LEFT_UPPER_INNER_EYE=[POINT_LEFT_UPPER_INNER_EYE_1,POINT_LEFT_UPPER_INNER_EYE_2,POINT_LEFT_UPPER_INNER_EYE_3,POINT_LEFT_UPPER_INNER_EYE_4,POINT_LEFT_UPPER_INNER_EYE_5,POINT_LEFT_UPPER_INNER_EYE_6,POINT_LEFT_UPPER_INNER_EYE_7,POINT_LEFT_UPPER_INNER_EYE_8,POINT_LEFT_UPPER_INNER_EYE_9]
|
| 210 |
+
LINE_LEFT_UPPER_INNER_EYE2=[POINT_LEFT_UPPER_INNER_EYE_1,POINT_LEFT_UPPER_INNER_EYE_2,POINT_LEFT_UPPER_INNER_EYE_3,POINT_LEFT_UPPER_INNER_EYE_4,POINT_LEFT_UPPER_INNER_EYE_5,POINT_LEFT_UPPER_INNER_EYE_6,POINT_LEFT_UPPER_INNER_EYE_7,POINT_LEFT_UPPER_INNER_EYE_8,POINT_LEFT_UPPER_INNER_EYE_9]
|
| 211 |
|
| 212 |
|
| 213 |
|
|
|
|
| 249 |
|
| 250 |
LINE_LEFT_UPPER_MIXED_EYE =[#firs eye1 and eye2 is intesionaly for moveup
|
| 251 |
[POINT_LEFT_UPPER_INNER_EYE_1,POINT_LEFT_UPPER_INNER_EYE_2,POINT_LEFT_LOWER_INNER_EYE_7],
|
| 252 |
+
[POINT_LEFT_UPPER_INNER_EYE_2,POINT_LEFT_UPPER_OUTER_EYE_2], [POINT_LEFT_UPPER_INNER_EYE_3,POINT_LEFT_UPPER_INNER_EYE_3,POINT_LEFT_UPPER_OUTER_EYE_3], [POINT_LEFT_UPPER_INNER_EYE_4,POINT_LEFT_UPPER_OUTER_EYE_4], [POINT_LEFT_UPPER_INNER_EYE_5,POINT_LEFT_UPPER_OUTER_EYE_5], [POINT_LEFT_UPPER_INNER_EYE_6,POINT_LEFT_UPPER_OUTER_EYE_6]
|
| 253 |
,[POINT_LEFT_UPPER_INNER_EYE_8],[POINT_LEFT_UPPER_OUTER_EYE_8,POINT_LEFT_UPPER_INNER_EYE_9]
|
| 254 |
]
|
| 255 |
+
|
| 256 |
+
LINE_LEFT_UPPER_MIXED_EYE2 =[#firs eye1 and eye2 is intesionaly for moveup
|
| 257 |
+
[POINT_LEFT_UPPER_INNER_EYE_1,POINT_LEFT_UPPER_INNER_EYE_1,POINT_LEFT_UPPER_INNER_EYE_2,POINT_LEFT_LOWER_INNER_EYE_7],
|
| 258 |
+
[POINT_LEFT_UPPER_INNER_EYE_2,POINT_LEFT_UPPER_INNER_EYE_2,POINT_LEFT_UPPER_OUTER_EYE_2],
|
| 259 |
+
[POINT_LEFT_UPPER_INNER_EYE_3,POINT_LEFT_UPPER_INNER_EYE_3,POINT_LEFT_UPPER_INNER_EYE_3,POINT_LEFT_UPPER_OUTER_EYE_3],
|
| 260 |
+
[POINT_LEFT_UPPER_INNER_EYE_4,POINT_LEFT_UPPER_INNER_EYE_4,POINT_LEFT_UPPER_OUTER_EYE_4],
|
| 261 |
+
[POINT_LEFT_UPPER_INNER_EYE_5,POINT_LEFT_UPPER_INNER_EYE_5,POINT_LEFT_UPPER_OUTER_EYE_5],
|
| 262 |
+
[POINT_LEFT_UPPER_INNER_EYE_6,POINT_LEFT_UPPER_INNER_EYE_6,POINT_LEFT_UPPER_OUTER_EYE_6]
|
| 263 |
+
,[POINT_LEFT_UPPER_INNER_EYE_8],
|
| 264 |
+
[POINT_LEFT_UPPER_OUTER_EYE_8,POINT_LEFT_UPPER_INNER_EYE_9]
|
| 265 |
+
]
|
| 266 |
+
|
| 267 |
LINE_LEFT_LOWER_MIXED_EYE =[
|
| 268 |
[POINT_LEFT_UPPER_OUTER_EYE_8,POINT_LEFT_UPPER_INNER_EYE_9]
|
| 269 |
,[POINT_LEFT_LOWER_INNER_EYE_2]
|