博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
深度学习与人脸识别之-脸部分割与校正
阅读量:671 次
发布时间:2019-03-15

本文共 791 字,大约阅读时间需要 2 分钟。

1.检测脸部

def read_im_and_landmarks(fname):    if not osp.exists(fname):        raise Exception('Cannot find image file: {}'.format(fname))    im = cv2.imread(fname, cv2.IMREAD_COLOR)    im = cv2.resize(im, (im.shape[1] * SCALE_FACTOR,                         im.shape[0] * SCALE_FACTOR))    s = get_landmarks(im)    return im, s

2.校正脸部

def calibrate(frame):        frame_new = numpy.clip(frame,0,255)    frame_new = numpy.uint8(frame_new)    frame_new = cv2.cvtColor(frame_new,cv2.COLOR_BGR2RGB)    dets = predictor_calibrate(frame_new, 1)        num_faces = len(dets)    if num_faces == 0:        print("Sorry, there were no faces found in current frame")        return None    faces = dlib.full_object_detections()    for detection in dets:        faces.append(sp(frame_new, detection))    i

转载地址:http://qgyqz.baihongyu.com/

你可能感兴趣的文章