Dlib + OpenCV Draw Points Landsmark

Dlib + OpenCV Draw Points Landsmark



I would like to draw contour of the cheek, as in the image below:
Example image



I am using OpenCV and Dlib to detect the landmarks, And I do not know how to manipulate the Dlib points. Does anyone know how I can make the contour on the cheek?



Here is my code:


import cv2
import dlib
import numpy as np


def imprimePontos (imagem, pontosFaciais):
for p in pontosFaciais.parts():
cv2.circle(imagem, (p.x, p.y), 2, (0, 255,0) ,4)

def imprimeNumeros (imagem, pontosFaciais):
for i, p in enumerate (pontosFaciais.parts()):
cv2.putText(imagem, str(i), (p.x, p.y), fonte, .55, (0, 0, 255),1)

def points (imagem, pontosFaciais): #here where a draw de points
p68 =[[15, 47, False],
[47, 28, False],
[28, 30, False],
[30, 12, False]]

for k in range(0, len(p68)):
pontos =
for i in range(p68[k] [0], p68[k][1] + 1):
ponto = [pontosFaciais.part(i).x, pontosFaciais.part(i).y]
pontos.append(ponto)
pontos = np.array(pontos, dtype=np.int32)
cv2.polylines(imagem, [pontos], p68 [k][2], (255, 0, 0), 2)

fonte = cv2.FONT_HERSHEY_COMPLEX_SMALL
imagem = cv2.imread('1.jpg')
detectorface = dlib.get_frontal_face_detector()
detectorpontosfaciais =
dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")
facesDetectadas = detectorface(imagem, 2)

for face in facesDetectadas:
pontos = detectorpontosfaciais(imagem, face)
print(pontos.parts())
#imprimePontos(imagem, pontos)
#imprimeNumeros(imagem, pontos)
points(imagem, pontos)


cv2.imshow("Bucheca", imagem)
cv2.waitKey()
cv2.destroyAllWindows()



This is my output:



Output image









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)