腾讯云人像变换---年龄变换测试

2021-05-11 14:40:25 浏览数 (2)

最近测试了下腾讯云的人像变换接口,文档地址在这边可以点击查看

打开接口文档后可以下载sdk测试使用,

源码安装只需要把对应jar包放到项目里即可

public static void main(String[] args) { // TODO Auto-generated method stub try { //通过secretid和key鉴权 Credential cred = new Credential("secretId", "secretKey"); HttpProfile httpProfile = new HttpProfile(); httpProfile.setEndpoint("ft.tencentcloudapi.com"); ClientProfile clientProfile = new ClientProfile(); clientProfile.setHttpProfile(httpProfile); //选择对应区域 FtClient client = new FtClient(cred, "ap-nanjing", clientProfile); ChangeAgePicRequest req = new ChangeAgePicRequest(); //输入图片地址参数 req.setUrl("http://pics6.baidu.com/feed/03087bf40ad162d92667e791ede60cea8b13cd77.jpeg?token=56cb20cec5c067cbaf9527a174343df0"); AgeInfo[] ageInfos1 = new AgeInfo[1]; AgeInfo ageInfo1 = new AgeInfo(); //输入要变换的年龄 ageInfo1.setAge(30L); ageInfos1[0] = ageInfo1; req.setAgeInfos(ageInfos1); //输入返回的图片格式 req.setRspImgType("url"); ChangeAgePicResponse resp = client.ChangeAgePic(req); System.out.println(ChangeAgePicResponse.toJsonString(resp)); } catch (TencentCloudSDKException e) { System.out.println(e.toString()); } }

返回结果:

{

"ResultImage":"",

"ResultUrl":"https://faceeffect-1254418846.cos.ap-guangzhou.myzijiebao.com/1258277710/1620704362827/Gnv0EIF2qld9Z",

"RequestId":"323bc1e6-6597-40a8-9036-b0619a634d4f"

}

变换的效果如图:

变换前变换前
变换后变换后

效果还行吧

0 人点赞