vs2015 c++ 调用百度 API人物转动漫算法

编程入门 行业动态 更新时间:2024-10-04 09:29:18

vs2015 c++ 调用百度 API人物转动漫<a href=https://www.elefans.com/category/jswz/34/1770096.html style=算法"/>

vs2015 c++ 调用百度 API人物转动漫算法

最初想自己用网上的开源代码及训练数据庥,后来发现百度有现成的,还可以免费调用500次,先试一下,等有业务了,再自己训练吧,先白嫖一下,毕竟业务量不大,功能只是展示用的

百度接口文档地址:

 

可以直接在在这个网址,用图片上传的形式,试一下是否满足你的效果:

 

 

可以后,开始注册帐号,密码,下载sdk.创建应用:

 

然后取得

AppID

API Key

Secret Key

 

然后下载sdk:

一定要下载4.1.15 ,之前版本没有这个接口

最后在程序中调用:

 

        #include "..\bdsdk/image_process.h"std::string app_id = "xxxxx";std::string api_key = "xxxxxxxxxxxxxxxx";std::string secret_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxj";aip::Imageprocess client(app_id, api_key, secret_key);Json::Value result;;std::string image;aip::get_file_content("test.jpg", &image);// 人像动漫化接口result = client.selfieanime(image, aip::null);std::string res = result["image"].asString();// convert string,asString(),std::string result_dec;//decode resultresult_dec = aip::base64_decode(res);std::vector<char> base64_img(result_dec.begin(), result_dec.end());cv::Mat img_decode = cv::imdecode(base64_img, CV_LOAD_IMAGE_COLOR);cv::Mat mask = img_decode * 255;cv::imwrite("C:\\GetAni67.png", img_decode);cv::imwrite("C:\\GetAni66.png", mask);

 

好了,搞定:

效果如下:

 

 

更多推荐

vs2015 c++ 调用百度 API人物转动漫算法

本文发布于:2024-02-27 22:32:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1766298.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:算法   人物   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!