作家
登录

小200行Python代码做了一个换脸程序

作者: 来源: 2018-03-22 17:06:36 阅读 我要评论

is because the above formulation assumes the matrix goes on the right 
  •     # (with row vectors) where as our solution requires the matrix to be on the 
  •     # left (with column vectors). 
  •     R = (U * Vt).T 
  •   
  •     return numpy.vstack([numpy.hstack(((s2 / s1) * R, 
  •                                        c2.T - (s2 / s1) * R * c1.T)), 
  •                          numpy.matrix([0., 0., 1.])]) 
  •   
  • def read_im_and_landmarks(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 
  •   
  • def warp_im(im, M, dshape): 
  •     output_im = numpy.zeros(dshape, dtype=im.dtype) 
  •     cv2.warpAffine(im, 
  •                    M[:2], 
  •                    (dshape[1], dshape[0]), 
  •                    dst=output_im, 
  •                    borderMode=cv2.BORDER_TRANSPARENT, 
  •                    flags=cv2.WARP_INVERSE_MAP) 
  •     return output_im 
  •   
  • def correct_colours(im1, im2, landmarks1): 
  •     blur_amount = COLOUR_CORRECT_BLUR_FRAC * numpy.linalg.norm( 
  •                               numpy.mean(landmarks1[LEFT_EYE_POINTS], axis=0) - 
  •                               numpy.mean(landmarks1[RIGHT_EYE_POINTS], axis=0)) 
  •     blur_amount = int(blur_amount) 
  •     if blur_amount % 2 == 0: 

  •   推荐阅读

      蜜月期还没过完 苹果就要和三星分手了

    全平易近充电节 | 3月26日~30日 2000位IT行业拭魅战专家邀请你一路充电进修! 作为手机阵营的两大年夜巨擘,苹不雅和三星因为一部iPhone X走在了一路,两边都大年夜中获得了本身想要的器械>>>详细阅读


    本文标题:小200行Python代码做了一个换脸程序

    地址:http://www.17bianji.com/lsqh/40825.html

    关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)