Giter Club home page Giter Club logo

facetoanimal's Introduction

faceToAnimal

主要流程:

打开图片,按比例缩小,重新存放; 上传缩小后图片,因上传的是缩小后图片,所有得到的也是缩小后的位点,需要同比例放大; 取我需要使用的四个点; 根据人脸大小计算动物头像大小,我是以下巴和鼻梁两点距离的两倍为脸的大小,然后同比例缩小放大头像到脸的两倍 根据两点之间的斜率求出脸的倾斜度,适当旋转头像; 以鼻梁的点为中心点和图片的大小,计算左上角位置贴上动物头像

*注意:动物头像必须为透明底的图片,在贴图时要转换weiRGN模式,否则会在图片空白处填充黑色

TencentYoutuyun介绍

TencentYoutuyun 依赖包 可到官网下载 api文档: https://github.com/Tencent-YouTu/Python_sdk 本次代码使用部分,跟多内容都在上面链接

import time
import TencentYoutuyun

appid = 'xxx'
secret_id = 'xxxxxxx'
secret_key = 'xxxxxxxx'
userid= 'xxx'

#end_point = TencentYoutuyun.conf.API_TENCENTYUN_END_POINT  // 腾讯云
#end_point = TencentYoutuyun.conf.API_YOUTU_VIP_END_POINT   // 人脸核身服务(需联系腾讯优图商务开通权限,否则无法使用)
end_point = TencentYoutuyun.conf.API_YOUTU_END_POINT        // 优图开放平台


youtu = TencentYoutuyun.YouTu(appid, secret_id, secret_key, userid, end_point)

ret = youtu.FaceShape(image_path='you_path.jpg', mode = 0, data_type = 0)
print ret

人脸位点信息:

https://open.youtu.qq.com/#/open/developer/face-point
本次只我使用第34,68,78,88点,分别是nose[1],face_profile[0],face_profile[10],face_profile[20]
字典结构也在链接中

PIL 图片处理

img = PIL.open(imagename) 打开图片
img.resize((x,y)) 改变图片大小
img.rotate(90) 逆时针90度
img.convert('RDBA') 图片转换为RGB模式
img.paste(img2,(x,y),mask=img2) 以img为背景把img2贴上,位置在(x,y)
img.show() 显示图片
img.size 图片大小

facetoanimal's People

Stargazers

文 avatar

Watchers

文 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.