faceSwap.py
def landmark_detection(self, img):
        """Generate facial landmark points of a give image.

        Parameters
        ----------
        img: nparray
            Readed value of an image.

        Returns
        -------
        faces_landmark_points : list
            return landmark points for every face in a given image.

        """

        # convert the image to greyscaleprint("land here")
        try:
            img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        except Exception:
            raise ValueError("image note found. ")

        # detect the face then find the landmarks points
        detector = dlib.get_frontal_face_detector()
        try:
            predictor = dlib.shape_predictor(
                'shape_predictor_68_face_landmarks.dat')
        except Exception:
            raise FileNotFoundError("the dlib model can't be found. ")

        try:
            faces = detector(img_gray)
        except Exception:
            raise ValueError("facial landmark points cann't be detected. ")
        faces_landmark_points = []
        for face in faces:
            landmarks = predictor(img_gray, face)
            landmark_points = []
            for n in range(68):
                x = landmarks.part(n).x
                y = landmarks.part(n).y
                landmark_points.append((int(x), int(y)))

            faces_landmark_points.append(landmark_points)

        return faces_landmark_points
Generate facial landmark points of a give image.

        Parameters
        ----------
        img: nparray
            Readed value of an image.

        Returns
        -------
        faces_landmark_points : list
            return landmark points for every face in a given image.

        
Generate facial landmark points of a give image.
Parameters

nparray
Readed value of an image.

Returns

faces_landmark_points : list
return landmark points for every face in a given image.
Generate facial landmark points of a give image . Parameters nparray Readed value of an image . Returns faces_landmark_points : list return landmark points for every face in a given image .
def landmark_detection(self, img):
        try:
            img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        except Exception:
            raise ValueError("image note found. ")
        detector = dlib.get_frontal_face_detector()
        try:
            predictor = dlib.shape_predictor(
                'shape_predictor_68_face_landmarks.dat')
        except Exception:
            raise FileNotFoundError("the dlib model can't be found. ")
        try:
            faces = detector(img_gray)
        except Exception:
            raise ValueError("facial landmark points cann't be detected. ")
        faces_landmark_points = []
        for face in faces:
            landmarks = predictor(img_gray, face)
            landmark_points = []
            for n in range(68):
                x = landmarks.part(n).x
                y = landmarks.part(n).y
                landmark_points.append((int(x), int(y)))
            faces_landmark_points.append(landmark_points)
        return faces_landmark_points
def landmark_detection ( self , img ) : try : img_gray = cv2 . cvtColor ( img , cv2 . COLOR_BGR2GRAY ) except Exception : raise ValueError ( "image note found. " ) detector = dlib . get_frontal_face_detector ( ) try : predictor = dlib . shape_predictor ( 'shape_predictor_68_face_landmarks.dat' ) except Exception : raise FileNotFoundError ( "the dlib model can't be found. " ) try : faces = detector ( img_gray ) except Exception : raise ValueError ( "facial landmark points cann't be detected. " ) faces_landmark_points = [ ] for face in faces : landmarks = predictor ( img_gray , face ) landmark_points = [ ] for n in range ( 68 ) : x = landmarks . part ( n ) . x y = landmarks . part ( n ) . y landmark_points . append ( ( int ( x ) , int ( y ) ) ) faces_landmark_points . append ( landmark_points ) return faces_landmark_points
Generate facial landmark points of a give image.
Generate facial landmark points of a give image .
"""Generate facial landmark points of a give image.

        Parameters
        ----------
        img: nparray
            Readed value of an image.

        Returns
        -------
        faces_landmark_points : list
            return landmark points for every face in a given image.

        """ # convert the image to greyscaleprint("land here") # detect the face then find the landmarks points
self
img