Example #1
0
def get_landmark(landmark_result, five=False):
    landmarks = landmark_result['result'][0]['landmark']
    five_organ = {}
    for key, value in landmarks.iteritems():
        if key.startswith('left_eye') or key.startswith('right_eye') \
                or key.startswith('nose') or key.startswith('mouth'):
            five_organ[key] = value
    print_result("five_organ", five_organ)
    if five == True:
        return five_organ
    else:
        return landmarks
Example #2
0
def get_landmark(landmark_result, five=False):
    landmarks = landmark_result['result'][0]['landmark']
    five_organ = {}
    for key, value in landmarks.iteritems():
        if key.startswith('left_eye') or key.startswith('right_eye') \
                or key.startswith('nose') or key.startswith('mouth'):
            five_organ[key] = value
    print_result("five_organ", five_organ)
    if five == True:
        return five_organ
    else:
        return landmarks
Example #3
0
def do_extract_face(img_path, five):
    global api
    time1 = time.time()
    #detection = api.detection.detect(url='http://www.huabian.com/uploadfile/2014/0821/20140821092236949.jpg')
    detection = api.detection.detect(img = File(img_path))
    face_id = get_face_id(detection)
    width, height = get_size(detection)
    landmark_result = api.detection.landmark(face_id=face_id)
    landmarks = get_landmark(landmark_result, five=five)

    # Debug
    print_result('anglebaby', detection)
    print '------------------------------'
    print_result('landmarks', landmarks)

    points_stack = get_points_stack(width, height, landmarks)
    print_result('points of landmarks', points_stack)

    edge_points = covex_hull(points_stack)
    print_result('edge points', edge_points)

    cut_and_save(img_path, edge_points)

    print 'Used time :', time.time() - time1
Example #4
0
def do_extract_face(img_path, five):
    global api
    time1 = time.time()
    #detection = api.detection.detect(url='http://www.huabian.com/uploadfile/2014/0821/20140821092236949.jpg')
    detection = api.detection.detect(img=File(img_path))
    face_id = get_face_id(detection)
    width, height = get_size(detection)
    landmark_result = api.detection.landmark(face_id=face_id)
    landmarks = get_landmark(landmark_result, five=five)

    # Debug
    print_result('anglebaby', detection)
    print '------------------------------'
    print_result('landmarks', landmarks)

    points_stack = get_points_stack(width, height, landmarks)
    print_result('points of landmarks', points_stack)

    edge_points = covex_hull(points_stack)
    print_result('edge points', edge_points)

    cut_and_save(img_path, edge_points)

    print 'Used time :', time.time() - time1