算法"/>
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人物转动漫算法
发布评论