效果图:
基本代码以前在前一篇中展示了,
主要是这边转码有点坑,第一种 不要urlencode,图片格式尽量要为jpg吧
//定义一个全局变量
private static int Result_num = 1;
var picclient = new Baidu.Aip.ImageClassify.ImageClassify("NpBGfUR6qBGtFo5bIFbiPCO9", "S0L7LXAewfW7BBKmbXd0EQ8iRzEYRGqc")
{
Timeout = 60000 // 修改超时时间
};
Image img = this.picbPreview.Image;
MemoryStream ms = new MemoryStream();
byte[] imagedata = null;
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
imagedata = ms.GetBuffer();
var picoptions = new Dictionary<string, object> {
{
"baike_num",Result_num } };
var results = picclient.AdvancedGeneral(imagedata, picoptions);
if (results != null && results.ToString() != null && results.ToString().Length > 0)
{
var json = JsonConvert.Serial