Last active
May 28, 2020 15:04
-
-
Save rajathithan/9e3ef6bff01843fa12569675be22123b to your computer and use it in GitHub Desktop.
opencv polylines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def drawPolyline(im, landmarks, start, end, isClosed=False): | |
points = [] | |
for i in range(start, end+1): | |
point = [landmarks.part(i).x, landmarks.part(i).y] | |
points.append(point) | |
points = np.array(points, dtype=np.int32) | |
cv2.polylines(im, [points], isClosed, (255, 200, 0), thickness=2, lineType=cv2.LINE_8) | |
# Use this function for 68-points facial landmark detector model | |
def renderFace(im, landmarks): | |
assert(landmarks.num_parts == 68) | |
drawPolyline(im, landmarks, 0, 16) # Jaw line | |
drawPolyline(im, landmarks, 17, 21) # Left eyebrow | |
drawPolyline(im, landmarks, 22, 26) # Right eyebrow | |
drawPolyline(im, landmarks, 27, 30) # Nose bridge | |
drawPolyline(im, landmarks, 30, 35, True) # Lower nose | |
drawPolyline(im, landmarks, 36, 41, True) # Left eye | |
drawPolyline(im, landmarks, 42, 47, True) # Right Eye | |
drawPolyline(im, landmarks, 48, 59, True) # Outer lip | |
drawPolyline(im, landmarks, 60, 67, True) # Inner lip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment