コード例 #1
0
    def __init__(self, landmarks: dict, img=None):
        # self.landmarks = landmarks
        self.image = img
        self.landmarks = landmarks

        # calculate
        self.left_eye_head = landmarks['43']
        self.left_eye_tail = landmarks['46']

        self.right_eye_head = landmarks['40']
        self.right_eye_tail = landmarks['37']

        self.left_eye_long = GeomTool.get_pt_dist(self.left_eye_tail, self.left_eye_head)
        self.right_eye_long = GeomTool.get_pt_dist(self.right_eye_tail, self.right_eye_head)

        self.eye_bar = GeomTool.get_pt_dist(self.left_eye_tail, self.right_eye_tail)
        self.eye_dist = GeomTool.get_pt_dist(self.left_eye_head, self.right_eye_head)

        self.val = (self.eye_bar - self.eye_dist) / self.eye_dist
        self.val_2 = (self.left_eye_long + self.right_eye_long) / self.eye_dist
        self.val_3 = (self.left_eye_long + self.right_eye_long) / (self.eye_dist * 2)
        self.val_4 = self.eye_bar / self.eye_dist

        # display
        self.red = (0, 0, 255)
        self.green = (0, 255, 0)
        self.thick = 2
コード例 #2
0
ファイル: cjwr.py プロジェクト: 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
コード例 #3
0
ファイル: tr.py プロジェクト: 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
コード例 #4
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
コード例 #5
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
コード例 #6
0
ファイル: nlj.py プロジェクト: jet-c-21/FAS
    def __init__(self, landmarks: dict, img=None):
        # self.landmarks = landmarks
        self.image = img
        self.landmarks = landmarks

        # calculate
        self.nose_bot = landmarks['34']
        self.lip_bot = landmarks['58']
        self.jaw_tip = landmarks['9']
        self.nasal_root = landmarks['28']

        self.face_height = GeomTool.get_pt_dist(self.nasal_root, self.jaw_tip)
        self.nose_lip = GeomTool.get_pt_dist(self.nose_bot, self.lip_bot)
        self.lip_jaw = GeomTool.get_pt_dist(self.lip_bot, self.jaw_tip)

        self.val = (self.nose_lip + self.lip_jaw) / self.face_height

        # display
        self.red = (0, 0, 255)
        self.green = (0, 255, 0)
        self.thick = 2

        # display
        self.red = (0, 0, 255)
        self.green = (0, 255, 0)
        self.thick = 2
コード例 #7
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
コード例 #8
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
コード例 #9
0
ファイル: heron.py プロジェクト: jet-c-21/FAS
 def GetAreaOfTriangle(p1, p2, p3):
     area = 0
     p1p2 = GeomTool.get_pt_dist(p1.arr, p2.arr)
     p2p3 = GeomTool.get_pt_dist(p2.arr, p3.arr)
     p3p1 = GeomTool.get_pt_dist(p3.arr, p1.arr)
     s = (p1p2 + p2p3 + p3p1) / 2
     area = s * (s - p1p2) * (s - p2p3) * (s - p3p1)  # 海倫公式
     area = math.sqrt(area)
     return area
コード例 #10
0
ファイル: cfi.py プロジェクト: 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
コード例 #11
0
ファイル: lmk_helper.py プロジェクト: jet-c-21/FAS
    def add_eye_mid(landmarks: dict) -> dict:
        # Get the middle of right eye
        right_eye_ql13 = (landmarks['42'], landmarks['39'])
        right_eye_ql24 = (landmarks['38'], landmarks['41'])
        right_eye_mid = GeomTool.get_line_intersect(right_eye_ql13, right_eye_ql24)
        landmarks['s1'] = right_eye_mid

        # Get the middle of left eye
        left_eye_ql13 = (landmarks['45'], landmarks['48'])
        left_eye_ql24 = (landmarks['44'], landmarks['47'])
        left_eye_mid = GeomTool.get_line_intersect(left_eye_ql13, left_eye_ql24)
        landmarks['s2'] = left_eye_mid

        return landmarks
コード例 #12
0
ファイル: lmk_helper.py プロジェクト: jet-c-21/FAS
    def add_lip_mid(landmarks: dict) -> dict:
        lip_vl = (landmarks['52'], landmarks['58'])
        lip_hl = (landmarks['49'], landmarks['55'])
        lip_mid = GeomTool.get_line_intersect(lip_vl, lip_hl)
        landmarks['s3'] = lip_mid

        return landmarks
コード例 #13
0
ファイル: lmk_helper.py プロジェクト: jet-c-21/FAS
    def get_face_scale(landmarks: dict) -> dict:
        result = dict()
        # horizontal scale
        result['hrz'] = GeomTool.get_pt_dist(landmarks['40'], landmarks['43'])

        # vertical scale
        vrt_top = GeomTool.get_pt_dist(landmarks['34'], landmarks['58'])
        vrt_bot = GeomTool.get_pt_dist(landmarks['58'], landmarks['9'])
        vrt_sum = vrt_top + vrt_bot
        vrt_mean = (vrt_top + vrt_bot) / 2
        result['vrt'] = vrt_sum
        result['vrt2'] = vrt_mean
        result['vrt3'] = vrt_top
        result['vrt4'] = vrt_bot

        return result
コード例 #14
0
 def rotater(image: numpy.ndarray, mode='fg', angle=None):
     temp = image.copy()
     if mode == 'fg':
         fg = FaceGrid(temp)
         fg.fetch()
         angle_to_hrzl = GeomTool.get_angle_to_hrzl(fg.fg_bot_left,
                                                    fg.fg_bot_right)
         return ImgProcTool.get_rotate_img(temp, angle_to_hrzl)
コード例 #15
0
    def __init__(self, landmarks: dict, img=None):
        self.image = img
        self.landmarks = landmarks

        # calculate
        self.bot_chin = self.get_bot_chin()
        self.bot_chin_area = GeomTool.get_polygon_area(self.bot_chin)
        self.bot_chin_perimeter = GeomTool.get_polygon_len(self.bot_chin)

        self.val = self.bot_chin_perimeter / self.bot_chin_area
        self.val_2 = self.bot_chin_area / self.bot_chin_perimeter

        # display
        self.red = (0, 0, 255)
        self.green = (0, 255, 0)
        self.yellow = (0, 255, 255)
        self.thick = 2
コード例 #16
0
    def rotate(self):
        angle_to_hrzl = GeomTool.get_angle_to_hrzl(self.face_grid.fg_bot_left,
                                                   self.face_grid.fg_bot_right)
        self.rt_image = ImgProcTool.get_rotate_img(self.image, angle_to_hrzl)

        if FBHelper.get_face_block(self.rt_image):
            return True
        else:
            print('Can not get face block from the rotated img - {}'.format(self.image_name))
            return False
コード例 #17
0
ファイル: fpya.py プロジェクト: jet-c-21/FAS
    def __init__(self, landmarks: dict, img=None):
        # self.landmarks = landmarks
        self.image = img
        self.landmarks = 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)

        self.cheek_fat = self.whole_face_area - self.face_pyramid_area

        self.val = self.whole_face_area / self.face_pyramid_area
        self.val_2 = self.face_pyramid_area / self.whole_face_area

        # display
        self.red = (0, 0, 255)
        self.green = (0, 255, 0)
        self.yellow = (0, 255, 255)
        self.thick = 2
コード例 #18
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
コード例 #19
0
ファイル: fmwr.py プロジェクト: 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
コード例 #20
0
ファイル: ed.py プロジェクト: jet-c-21/FAS
    def __init__(self, landmarks: dict, img=None):
        # self.landmarks = landmarks
        self.image = img
        self.landmarks = landmarks

        ## calculate
        self.left_eye_head = landmarks['43']
        self.right_eye_head = landmarks['40']
        self.eye_dist = GeomTool.get_pt_dist(self.left_eye_head,
                                             self.right_eye_head)

        self.nasal_root = landmarks['28']
        self.nose_tip = landmarks['31']
        self.nose_bridge = GeomTool.get_pt_dist(self.nasal_root, self.nose_tip)

        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)

        # vertical
        self.nose_bot = landmarks['34']
        self.moth_top = landmarks['52']
        self.philtrum = GeomTool.get_pt_dist(self.nose_bot, self.moth_top)

        # whole face vertical
        self.nasal_root = landmarks['28']
        self.jaw_tip = landmarks['9']
        self.face_height = GeomTool.get_pt_dist(self.nasal_root, self.jaw_tip)

        # self.val = (self.eye_dist * self.nose_bridge) / (self.cheek_width * self.face_height)
        self.val = self.eye_dist / self.cheek_width

        # display
        self.red = (0, 0, 255)
        self.green = (0, 255, 0)
        self.thick = 2
コード例 #21
0
ファイル: heron.py プロジェクト: jet-c-21/FAS
    def get_perimeter(points: list) -> float:
        points = HeronMethod.polygon_pt_sort(points)
        result = 0
        for index, point in enumerate(points):
            dest_index = index + 1
            if dest_index < len(points):
                dest_point = points[dest_index]

            else:
                dest_index = 0
                dest_point = points[dest_index]

            result += GeomTool.get_pt_dist(point, dest_point)

        return result
コード例 #22
0
ファイル: lmk_helper.py プロジェクト: jet-c-21/FAS
 def get_fg_top_right(cheek_left: tuple, top_line: tuple):
     return GeomTool.get_prj_point(cheek_left, top_line)
コード例 #23
0
ファイル: lmk_helper.py プロジェクト: jet-c-21/FAS
 def get_fg_bot_right(jaw_tip: tuple, right_line: tuple):
     return GeomTool.get_prj_point(jaw_tip, right_line)
コード例 #24
0
ファイル: lmk_helper.py プロジェクト: jet-c-21/FAS
 def get_edge_points(landmarks: dict, top_line: tuple) -> (tuple, tuple):
     # sorted_lmks = sorted(landmarks.items(), key=lambda x: x[1][0])
     sorted_lmks = sorted(landmarks.items(), key=lambda x: GeomTool.get_prj_point(x[1], top_line)[0])
     return sorted_lmks[0][1], sorted_lmks[-1][1]
コード例 #25
0
ファイル: lmk_helper.py プロジェクト: jet-c-21/FAS
 def get_fg_bot_left(jaw_tip: tuple, left_line: tuple):
     return GeomTool.get_prj_point(jaw_tip, left_line)