Example #1
0
    def get_face_landmarks(self):
        self.__resize_image()
        stasm.init()
        stasm.open_image(self.img, multiface=True)
        self.landmarks = stasm.search_auto()

        if len(self.landmarks) == 0:
            print "Error in get_face_landmarks(): Cannot find face", self.path
            self.landmarks = None
        else:
            self.landmarks = stasm.force_points_into_image(self.landmarks, self.img)
            self.landmarks = stasm.convert_shape(self.landmarks, stasm.MUCT76)
        stasm.init()
        self.__coordinate_correction()
Example #2
0
    def get_face_landmarks(self):
        self.__resize_image()
        stasm.init()
        stasm.open_image(self.img, multiface=True)
        self.landmarks = stasm.search_auto()

        if len(self.landmarks) == 0:
            print "Error in get_face_landmarks(): Cannot find face", self.path
            self.landmarks = None
        else:
            self.landmarks = stasm.force_points_into_image(
                self.landmarks, self.img)
            self.landmarks = stasm.convert_shape(self.landmarks, stasm.MUCT76)
        stasm.init()
        self.__coordinate_correction()
path = os.path.join(
    stasm.DATADIR,
    '/home/shivani/Pictures/cohn-kanade-images-extracted/S052_001_00000001.png'
)
path2 = os.path.join(
    stasm.DATADIR,
    '/home/shivani/Pictures/cohn-kanade-images-extracted/S052_001_00000015.png'
)
img = cv2.imread(path, cv2.IMREAD_GRAYSCALE)
img2 = cv2.imread(path2, cv2.IMREAD_GRAYSCALE)
if img is None:
    print("Cannot load", path)
    raise SystemExit

stasm.init()
stasm.open_image(img)
landmarks = stasm.search_auto()

stasm.open_image(img2)
landmarks2 = stasm.search_auto()

canvas = np.zeros((490, 640, 3), np.uint8)

#ht, wd = cv2.GetSize(img)
print img.shape
#ht, wd = cv2.GetSize(img2)
print img2.shape

print canvas.shape

import os.path
import cv2
import stasm

path = os.path.join(stasm.DATADIR, '/home/shivani/Pictures/cohn-kanade-images-extracted/S132_006_00000023.png')

img = cv2.imread(path, cv2.IMREAD_GRAYSCALE)

if img is None:
	print("Cannot load", path)
	raise SystemExit

stasm.init()
stasm.open_image(img)

landmarks = stasm.search_auto()

if len(landmarks) == 0:
	print("No face found in", path)
else:
	landmarks = stasm.force_points_into_image(landmarks, img)
	for point in landmarks:
		x=round(point[1])
		y=round(point[0])
		img[x-1][y-1] = 0
		img[x-1][y] = 0
		img[x-1][y+1] = 0
		img[x][y-1] = 0
		img[x][y] = 0
		img[x][y+1] = 0
		img[x+1][y-1] = 0