Created
December 3, 2019 17:08
-
-
Save kaushil24/8d53e41fa16420bfc4f1e6e1b175754c to your computer and use it in GitHub Desktop.
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 drawEyeliner(img, interp_pts): | |
L_eye_interp, R_eye_interp = interp_pts | |
L_interp_x, L_interp_top_y, L_interp_bottom_y = L_eye_interp | |
R_interp_x, R_interp_top_y, R_interp_bottom_y = R_eye_interp | |
overlay = img.copy() | |
# overlay = np.empty(img.shape) | |
# overlay = np.zeros_like(img) | |
for i in range(len(L_interp_x)-2): | |
x1 = L_interp_x[i] | |
y1_top = L_interp_top_y[i] | |
x2 = L_interp_x[i+1] | |
y2_top = L_interp_top_y[i+1] | |
cv2.line(overlay, (x1, y1_top), (x2, y2_top), color, thickness) | |
y1_bottom = L_interp_bottom_y[i] | |
y2_bottom = L_interp_bottom_y[i+1] | |
cv2.line(overlay, (x1, y1_bottom), (x1, y2_bottom), color, thickness) | |
for i in range(len(R_interp_x)-2): | |
x1 = R_interp_x[i] | |
y1_top = R_interp_top_y[i] | |
x2 = R_interp_x[i+1] | |
y2_top = R_interp_top_y[i+1] | |
cv2.line(overlay, (x1, y1_top), (x2, y2_top), color, thickness) | |
y1_bottom = R_interp_bottom_y[i] | |
y2_bottom = R_interp_bottom_y[i+1] | |
cv2.line(overlay, (x1, y1_bottom), (x1, y2_bottom), color, thickness) | |
# background = Image.fromarray(img) # .convert("1") | |
# foreground = Image.fromarray(overlay).convert("1") | |
# newImg = Image.composite(foreground, background, foreground)#, mask='1') | |
# # img = cv2.bitwise_and(overlay, img) | |
# return cv2.cvtColor(np.array(newImg), cv2.COLOR_RGB2BGR) | |
return overlay |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment