输入限制
图片格式:JPEG、JPG、BMP、PNG。
图片大小:大小不超过3MB。
图片分辨率:分辨率要求小于1200×1200像素。
图像都必须是RGB 3通道。
URL地址中不能包含中文字符。
请求参数
返回数据
错误码
示例
请求示例
&MajorUrl=http://ivpd-demo.oss-cn-shanghai.aliyuncs.com/ivpd-demo/images/ExtendImageStyle/majorUrl.jpeg
&StyleUrl=http://ivpd-demo.oss-cn-shanghai.aliyuncs.com/ivpd-demo/images/ExtendImageStyle/styleUrl.jpeg
&<公共请求参数>
正常返回示例
"Data": {
"Url": "http://ivpd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/upload/result_/2019-11-21/invi__015743391278011000102_oRkJ4W.jpg?Expires=1574598327&OSSAccessKeyId=LTAI4FeJ8qKkYn6SrHhQ****&Signature=8%2B65JsTvfxXjKtc2ztKGw%2BxxmL****"
},
"RequestId": "F1ABC965-2612-4680-9DE3-B5C77434B9B7"
}
图片:
风格参考图片:
合成图:
核心代码:
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import com.google.gson.Gson;
import java.util.*;
public class ExtendImageStyle {
public static void main(String[] args) {
DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "<accessKeyId>", "<accessSecret>");
IAcsClient client = new DefaultAcsClient(profile);
ExtendImageStyleRequest request = new ExtendImageStyleRequest();
request.setRegionId("cn-shanghai");
request.setMajorUrl("http://explorer-image.oss-cn-shanghai.aliyuncs.com/iskjCQfNe0cJ_zLOydKNQxVp/%E8%9C%82%E8%9C%9C%E6%B5%8F%E8%A7%88%E5%99%A8_%E6%BE%B9%E4%BD%BA%E7%84%8A_4.jpg?OSSAccessKeyId=LTAI4Fk9FstqSEYnqKJ5Dpeo&Expires=1604383888&Signature=CqDBEvD%2BRZsxp%2Ffuyz3Lo4GTRUw%3D");
request.setStyleUrl("http://viapi-test.oss-cn-shanghai.aliyuncs.com/sanjiye-meizi/%E5%9B%BE%E5%83%8F%E5%A2%9E%E5%BC%BA/%E9%A3%8E%E6%A0%BC%E8%BF%81%E7%A7%BB1.jpg");
try {
ExtendImageStyleResponse response = client.getAcsResponse(request);
System.out.println(new Gson().toJson(response));
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
System.out.println("ErrCode:" + e.getErrCode());
System.out.println("ErrMsg:" + e.getErrMsg());
System.out.println("RequestId:" + e.getRequestId());
}
}
}
总结:通过这些天的学习,我明白了视觉产生方面的许多知识和技巧,明白了框架的重要性和协调性。这篇文章所述内容实现了不同图片之间的风格迁移,也是我很喜欢的一项功能,希望各位小伙伴能够从怀收获知识。
参考链接:https://vision.aliyun.com/experience/detail?spm=a211p3.14471187.J_7524944390.19.6e92797duEBsEB&tagName=imageenhan&children=ExtendImageStyle