faceSwap.py
def calculateDelaunayTriangles(self, img, points):
        """Calculate delauney triangles of a give points.

        Parameters
        ----------
        image : str
            image file path.
        points : list
            landmark points of the image.

        Returns
        -------
        delaunayTri_indexes : list
            return a list tuple integer contain the indexes of the landmark points.

        """

        # img = cv2.imread(image)
        rect = (0, 0, img.shape[1], img.shape[0])

        subdiv = cv2.Subdiv2D(rect)
        subdiv.insert(points)
        triangleList = subdiv.getTriangleList()

        delaunayTri_indexes = []

        for t in triangleList:

            pt1 = (t[0], t[1])
            pt2 = (t[2], t[3])
            pt3 = (t[4], t[5])
            pts = [pt1, pt2, pt3]

            index = []
            # Get face-points (from 68 face detector) by coordinates
            for i in range(3):
                for j in range(0, len(points)):
                    if(pts[i][0] == points[j][0] and pts[i][1] == points[j][1]):
                        index.append(j)
            # Three points form a triangle
            if len(index) == 3:
                delaunayTri_indexes.append((index[0], index[1], index[2]))

        return delaunayTri_indexes
Calculate delauney triangles of a give points.

        Parameters
        ----------
        image : str
            image file path.
        points : list
            landmark points of the image.

        Returns
        -------
        delaunayTri_indexes : list
            return a list tuple integer contain the indexes of the landmark points.

        
Calculate delauney triangles of a give points.
Parameters

image : str
image file path.
points : list
landmark points of the image.

Returns

delaunayTri_indexes : list
return a list tuple integer contain the indexes of the landmark points.
Calculate delauney triangles of a give points . Parameters image : str image file path . points : list landmark points of the image . Returns delaunayTri_indexes : list return a list tuple integer contain the indexes of the landmark points .
def calculateDelaunayTriangles(self, img, points):
        rect = (0, 0, img.shape[1], img.shape[0])
        subdiv = cv2.Subdiv2D(rect)
        subdiv.insert(points)
        triangleList = subdiv.getTriangleList()
        delaunayTri_indexes = []
        for t in triangleList:
            pt1 = (t[0], t[1])
            pt2 = (t[2], t[3])
            pt3 = (t[4], t[5])
            pts = [pt1, pt2, pt3]
            index = []
            for i in range(3):
                for j in range(0, len(points)):
                    if(pts[i][0] == points[j][0] and pts[i][1] == points[j][1]):
                        index.append(j)
            if len(index) == 3:
                delaunayTri_indexes.append((index[0], index[1], index[2]))
        return delaunayTri_indexes
def calculateDelaunayTriangles ( self , img , points ) : rect = ( 0 , 0 , img . shape [ 1 ] , img . shape [ 0 ] ) subdiv = cv2 . Subdiv2D ( rect ) subdiv . insert ( points ) triangleList = subdiv . getTriangleList ( ) delaunayTri_indexes = [ ] for t in triangleList : pt1 = ( t [ 0 ] , t [ 1 ] ) pt2 = ( t [ 2 ] , t [ 3 ] ) pt3 = ( t [ 4 ] , t [ 5 ] ) pts = [ pt1 , pt2 , pt3 ] index = [ ] for i in range ( 3 ) : for j in range ( 0 , len ( points ) ) : if ( pts [ i ] [ 0 ] == points [ j ] [ 0 ] and pts [ i ] [ 1 ] == points [ j ] [ 1 ] ) : index . append ( j ) if len ( index ) == 3 : delaunayTri_indexes . append ( ( index [ 0 ] , index [ 1 ] , index [ 2 ] ) ) return delaunayTri_indexes
Calculate delauney triangles of a give points.
Calculate delauney triangles of a give points .
"""Calculate delauney triangles of a give points.

        Parameters
        ----------
        image : str
            image file path.
        points : list
            landmark points of the image.

        Returns
        -------
        delaunayTri_indexes : list
            return a list tuple integer contain the indexes of the landmark points.

        """ # img = cv2.imread(image) # Get face-points (from 68 face detector) by coordinates # Three points form a triangle
self
img
points