<jupyter_start><jupyter_text><jupyter_code>#!curl -o myPic.png https://d1qsx5nyffkra9.cloudfront.net/sites/default/files/article-image/eminence-organics-acne-face-mapping.jpg
import cv2 as cv
from matplotlib import pyplot as plt
import numpy as np
import dlib
from google.colab.patches import cv2_imshow

detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor("drive/My Drive/Colab Notebooks/shape_predictor_68_face_landmarks.dat")

def createBox(img, points, scale = 5, masked= False, cropped = True):
  if masked:
    mask = np.zeros_like(img)
    mask = cv.fillPoly(mask, [points], (255,255,255))
    img = cv.bitwise_and(img, mask)
  
  if cropped:
    cropBox = cv.boundingRect(points)
    x,y,w,h = cropBox
    imgCrop = img[y:y+h,x:x+w] 
    imgCrop = cv.resize(imgCrop, (0,0), None, scale, scale)
    return imgCrop
  
  else:
    return mask

img = cv.imread("drive/My Drive/Memories/myPic.jpg", 1)
img = cv.resize(img, (0,0), None, 2, 2)
imgOriginal= img.copy()
imgGray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
faces = detector(imgGray)

for face in faces:
  x1,y1 = face.left(),face.top()
  x2,y2 = face.right(),face.bottom()
  cv.rectangle(imgOriginal, (x1,y1),(x2,y2), (0,255,0))
  landmarks = predictor(imgGray, face) 
  myPoints = []

  for n in range(68):
    x = landmarks.part(n).x
    y = landmarks.part(n).y
    myPoints.append([x,y])
    #cv.circle(imgOriginal, (x,y), 3, (255,255,255), cv.FILLED)
    cv.putText(imgOriginal, str(n), (x,y-4), cv.FONT_HERSHEY_COMPLEX_SMALL, 0.6, (0,0,0), 1)

  print(myPoints)
  myPoints= np.array(myPoints)

  lips = createBox(img, myPoints[42:48], masked = True, cropped = False)
  colorLips = np.zeros_like(lips)
  colorLips[:] = 0,0,255
  colorLips = cv.bitwise_and(lips, colorLips)
  colorLips = cv.GaussianBlur(colorLips, (7,7), 50)
  colorLips = cv.addWeighted(img, 1, colorLips, 0.4, 0)
  cv2_imshow(colorLips)

cv2_imshow(result)
cv2_imshow(img)
cv2_imshow(imgOriginal)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15042907622412924, 'fraction_numerical': 0.03937405350832913, 'mean_word_length': 4.630681818181818, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '385260', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 880, 'n_tokens_neox': 825, 'n_words': 153, 'path': 'LandMarkDetection.ipynb', 'repo_name': 'BinayakDotel/opencv', 'size': '1981'}