Ejemplo n.º 1
0
    def __init__(self, landmarks: dict, img=None):
        self.image = img
        self.landmarks = landmarks
        self.face_scale = LMKHelper.get_face_scale(self.landmarks)

        # calculate
        self.left_cheek = self.landmarks['3']
        self.right_cheek = self.landmarks['15']
        self.cheek_width = GeomTool.get_pt_dist(self.left_cheek,
                                                self.right_cheek)

        self.nasal_root = self.landmarks['28']
        self.jaw_tip = self.landmarks['9']
        # Lower Face Height (lft)
        self.njh = GeomTool.get_pt_dist(self.nasal_root, self.jaw_tip)

        self.val = self.cheek_width / self.njh
        self.val_2 = (self.cheek_width * self.face_scale['vrt']) / (
            self.njh * self.face_scale['hrz'])
        self.val_3 = (self.cheek_width * self.face_scale['vrt2']) / (
            self.njh * self.face_scale['hrz'])
        self.val_4 = (self.cheek_width * self.face_scale['vrt3']) / (
            self.njh * self.face_scale['hrz'])
        self.val_5 = (self.cheek_width * self.face_scale['vrt4']) / (
            self.njh * self.face_scale['hrz'])

        # display
        self.red = (0, 0, 255)
        self.green = (0, 255, 0)
        self.thick = 2
Ejemplo n.º 2
0
    def __init__(self, landmarks: dict, img=None):
        self.image = img
        self.landmarks = landmarks
        self.face_scale = LMKHelper.get_face_scale(self.landmarks)

        # calculate
        self.right_jaw = self.landmarks['5']
        self.left_jaw = self.landmarks['13']
        self.jaw_width = GeomTool.get_pt_dist(self.right_jaw, self.left_jaw)

        self.nasal_root = self.landmarks['28']
        self.prj_point = GeomTool.get_prj_point(
            self.nasal_root, (self.left_jaw, self.right_jaw))
        self.lower_face_height = GeomTool.get_pt_dist(self.nasal_root,
                                                      self.prj_point)

        self.val = (self.jaw_width * self.lower_face_height) / (
            self.face_scale['hrz'] * self.face_scale['vrt'])
        self.val_2 = (self.jaw_width * self.lower_face_height) / (
            self.face_scale['hrz'] * self.face_scale['vrt2'])
        self.val_3 = (self.jaw_width * self.lower_face_height) / (
            self.face_scale['hrz'] * self.face_scale['vrt3'])
        self.val_4 = (self.jaw_width * self.lower_face_height) / (
            self.face_scale['hrz'] * self.face_scale['vrt4'])

        # display
        self.red = (0, 0, 255)
        self.tiff_blue = (208, 216, 129)
        self.thick = 2
Ejemplo n.º 3
0
    def __init__(self, landmarks: dict, img=None):
        # self.landmarks = landmarks
        self.image = img
        self.landmarks = landmarks
        self.face_scale = LMKHelper.get_face_scale(self.landmarks)

        # calculate
        self.left_cheek = self.landmarks['17']
        self.right_cheek = self.landmarks['1']
        self.cheek_width = GeomTool.get_pt_dist(self.left_cheek, self.right_cheek)

        self.nasal_root = self.landmarks['28']
        self.lip_top = self.landmarks['52']
        # Lower Face Height (lft)
        self.nlh = GeomTool.get_pt_dist(self.nasal_root, self.lip_top)

        self.val = (self.cheek_width * self.nlh) / (self.face_scale['hrz'] * self.face_scale['vrt'])
        self.val_2 = (self.cheek_width * self.nlh) / (self.face_scale['hrz'] * self.face_scale['vrt2'])
        self.val_3 = (self.cheek_width * self.nlh) / (self.face_scale['hrz'] * self.face_scale['vrt3'])
        self.val_4 = (self.cheek_width * self.nlh) / (self.face_scale['hrz'] * self.face_scale['vrt4'])

        # display
        self.red = (0, 0, 255)
        self.tiff_blue = (208, 216, 129)
        self.thick = 2
Ejemplo n.º 4
0
Archivo: tr.py Proyecto: jet-c-21/FAS
    def __init__(self, landmarks: dict, img=None):
        self.image = img
        self.landmarks = landmarks
        self.face_scale = LMKHelper.get_face_scale(self.landmarks)

        # calculate
        self.left_cheek = self.landmarks['17']
        self.right_cheek = self.landmarks['1']
        self.cheek_width = GeomTool.get_pt_dist(self.left_cheek,
                                                self.right_cheek)

        self.jaw_tip = landmarks['9']
        self.prj_point = GeomTool.get_prj_point(
            self.jaw_tip, (self.left_cheek, self.right_cheek))
        # Lower Face Height (lft)
        self.lft = GeomTool.get_pt_dist(self.jaw_tip, self.prj_point)

        self.val = (self.cheek_width * self.face_scale['vrt']) / (
            self.lft * self.face_scale['hrz'])
        self.val_2 = (self.cheek_width * self.face_scale['vrt2']) / (
            self.lft * self.face_scale['hrz'])
        self.val_3 = (self.cheek_width * self.face_scale['vrt3']) / (
            self.lft * self.face_scale['hrz'])
        self.val_4 = (self.cheek_width * self.face_scale['vrt4']) / (
            self.lft * self.face_scale['hrz'])

        # display
        self.red = (0, 0, 255)
        self.green = (0, 255, 0)
        self.thick = 2
Ejemplo n.º 5
0
    def __init__(self, landmarks: dict, img=None, calc_mode=None):
        # self.landmarks = landmarks
        self.image = img
        self.landmarks = landmarks
        self.calc_mode = calc_mode
        self.face_scale = LMKHelper.get_face_scale(self.landmarks)

        # calculate
        self.face_coords = self.get_face_coords()
        self.face_area = GeomTool.get_polygon_area(self.face_coords)

        self.left_eye_tail = self.landmarks['37']
        self.right_eye_tail = self.landmarks['46']
        self.left_mouth = self.landmarks['49']
        self.right_mouth = self.landmarks['55']
        self.face_trapezoid = [self.left_eye_tail, self.left_mouth, self.right_mouth, self.right_eye_tail]
        self.ft_area = GeomTool.get_polygon_area(self.face_trapezoid)

        self.val = self.ft_area / self.face_area
        self.val_2 = self.face_area / self.ft_area

        # display
        self.red = (0, 0, 255)
        self.green = (0, 255, 0)
        self.thick = 2
Ejemplo n.º 6
0
Archivo: cjwr.py Proyecto: jet-c-21/FAS
    def __init__(self, landmarks: dict, img=None):
        self.image = img
        self.landmarks = landmarks
        self.face_scale = LMKHelper.get_face_scale(self.landmarks)

        # calculate
        # cheek part
        self.left_cheek = self.landmarks['17']
        self.right_cheek = self.landmarks['1']
        self.cheek_width = GeomTool.get_pt_dist(self.left_cheek,
                                                self.right_cheek)

        # jaw part
        self.right_jaw = self.landmarks['5']
        self.left_jaw = self.landmarks['13']
        self.jaw_width = GeomTool.get_pt_dist(self.right_jaw, self.left_jaw)

        self.val = self.jaw_width / self.cheek_width
        self.val_2 = (self.jaw_width *
                      self.cheek_width) / (self.face_scale['hrz']**2)

        # display
        self.red = (0, 0, 255)
        self.green = (0, 255, 0)
        self.thick = 2
Ejemplo n.º 7
0
    def can_find_landmarks(self) -> bool:
        self.landmarks = LMKHelper.get_landmarks(self.image, self.face_block)
        if self.landmarks:
            return True

        else:
            self.msg = '無法獲取照片中人臉的特徵'
            print('[LOCAL] - {} - {}'.format(__name__, self.msg))
            return False
Ejemplo n.º 8
0
    def check_dlib_acc(self, image: numpy.ndarray) -> tuple:
        result = False
        isf_wizard = ISFWizard(self.isf_model, image)
        isf_wizard.launch()
        if not isf_wizard:
            return result, isf_wizard
        isf_lmks = isf_wizard.isf_lmks

        fb_temp = FBHelper.get_face_block(image)
        if not fb_temp:
            print('[LOCAL] - {} - 找不到 Face Block'.format(__name__))
            return result, isf_wizard
        dlib_lmks = LMKHelper.get_landmarks(image, fb_temp)

        dlib_acc = LMKHelper.get_lmks_acc(dlib_lmks, isf_lmks)

        if dlib_acc < 0.05:
            result = True

        return result, isf_wizard
Ejemplo n.º 9
0
Archivo: cfi.py Proyecto: jet-c-21/FAS
    def __init__(self, landmarks: dict, img=None):
        # self.landmarks = landmarks
        self.image = img
        self.landmarks = landmarks
        self.face_scale = LMKHelper.get_face_scale(self.landmarks)

        # calculate
        self.face_pyramid = self.get_face_pyramid()
        self.face_pyramid_area = GeomTool.get_polygon_area(self.face_pyramid)

        self.whole_face = self.get_whole_face()
        self.whole_face_area = GeomTool.get_polygon_area(self.whole_face)

        # basic point
        self.left_cheek = self.landmarks['17']
        self.right_cheek = self.landmarks['1']
        self.jaw_tip = self.landmarks['9']

        # support point
        self.prj_point = GeomTool.get_prj_point(
            self.jaw_tip, (self.left_cheek, self.right_cheek))

        # the distance between horizontal line and jaw tip
        self.prj_jaw = GeomTool.get_pt_dist(self.jaw_tip, self.prj_point)

        # the distance between nasal root and jaw tip
        self.nasal_root = self.landmarks['28']
        self.nasal_jaw = GeomTool.get_pt_dist(self.nasal_root, self.jaw_tip)

        self.cheek_fat = self.whole_face_area - self.face_pyramid_area
        self.cheek_fat_ratio = self.cheek_fat / self.whole_face_area

        # CFR val
        self.val = self.cheek_fat_ratio / self.prj_jaw
        self.val_2 = self.cheek_fat_ratio / self.nasal_jaw

        self.val_3 = (self.cheek_fat_ratio *
                      self.face_scale['vrt']) / self.prj_jaw
        self.val_4 = (self.cheek_fat_ratio *
                      self.face_scale['vrt2']) / self.prj_jaw

        self.val_5 = (self.cheek_fat_ratio *
                      self.face_scale['vrt']) / self.nasal_jaw
        self.val_6 = (self.cheek_fat_ratio *
                      self.face_scale['vrt2']) / self.nasal_jaw

        # display
        self.red = (0, 0, 255)
        self.green = (0, 255, 0)
        self.purple = (128, 0, 128)
        self.yellow = (0, 255, 255)
        self.thick = 2
Ejemplo n.º 10
0
    def __init__(self, landmarks: dict, img=None, calc_mode=None):
        # self.landmarks = landmarks
        self.image = img
        self.landmarks = landmarks
        self.calc_mode = calc_mode
        self.face_scale = LMKHelper.get_face_scale(self.landmarks)

        # calculate
        self.face_coords = self.get_face_coords()
        self.face_area = GeomTool.get_polygon_area(self.face_coords)
        self.face_perimeter = GeomTool.get_polygon_len(self.face_coords)

        self.val = self.face_perimeter / self.face_area
        self.val_2 = (self.face_perimeter *
                      (self.face_scale['hrz'] + self.face_scale['vrt']) *
                      2) / (self.face_area * self.face_scale['hrz'] *
                            self.face_scale['vrt'])

        # display
        self.red = (0, 0, 255)
        self.green = (0, 255, 0)
        self.thick = 2
Ejemplo n.º 11
0
Archivo: fmwr.py Proyecto: jet-c-21/FAS
    def __init__(self, landmarks: dict, img=None):
        self.image = img
        self.landmarks = landmarks
        self.face_scale = LMKHelper.get_face_scale(self.landmarks)

        # calculate
        self.right_jaw = self.landmarks['4']
        self.left_jaw = self.landmarks['14']
        self.jaw_width = GeomTool.get_pt_dist(self.right_jaw, self.left_jaw)

        self.mouth_left = self.landmarks['49']
        self.mouth_right = self.landmarks['55']
        self.mouth_width = GeomTool.get_pt_dist(self.mouth_left, self.mouth_right)

        self.val = self.jaw_width / self.mouth_width
        self.val_2 = (self.jaw_width * self.mouth_width) / (self.face_scale['hrz'] ** 2)

        # display
        self.red = (0, 0, 255)
        self.green = (0, 255, 0)
        self.yellow = (255, 255, 0)
        self.purple = (128, 0, 128)
        self.thick = 2
Ejemplo n.º 12
0
 def load_landmarks(self):
     self.landmarks = LMKHelper.get_landmarks(self.image, self.face_block)