赞
踩
效果图
步骤一:登录百度智能云在产品服务--->图像增强与特效下面新建应用
步骤二:获取用户的API Key和Secret Key
步骤三:1.调用接口获取token
- https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=上面的id&client_secret=上面的id
-
- 返回的结果
- {
- "refresh_token": "25.b55fe1d287227ca97aab219bb249b8ab.315360000.1798284651.282335-8574074",
- "expires_in": 2592000,
- "scope": "public wise_adapt",
- "session_key": "9mzdDZXu3dENdFZQurfg0Vz8slgSgvvOAUebNFzyzcpQ5EnbxbF+hfG9DQkpUVQdh4p6HbQcAiz5RmuBAja1JJGgIdJI",
- "access_token": "24.6c5e1ff107f0e8bcef8c46d3424a0e78.2592000.1485516651.282335-8574074",
- "session_secret": "dfac94a3489fe9fca7c3221cbf7525ff"
- }
2.根据上面获取的token来调用人像动漫化的接口
- uni.request({
- url: 'https://aip.baidubce.com/rest/2.0/image-process/v1/selfie_anime',
- method: 'POST',
- data: {
- image: 'base64',
- type: 'anime', // anime或者anime_mask。前者生成二次元动漫图,后者生成戴口罩的二次元动漫人像
- access_token: token
- },
- header: {
- "content-type": "application/x-www-form-urlencoded"
- },
- success: (res) => {
- console.log('访问成功:', res);
- }
- })
这样就大功告成了,顺便吐槽一句感觉不太像哈哈哈
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。