python校正人脸_深度学习与人脸识别之-脸部分割与校正

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))

images = dlib.get_face_chips(frame_new, faces, size=150)

return images

3.脸部分割效果:

4.脸部校正效果

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值