zhaojs
2023-09-15 fc13938ff90213060532d99a600dea4a84456885
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using Baidu.Aip.Ocr;
using CommonUtil;
using System;
 
namespace BaiDuSdk
{
    public class BaiDuClient
    {
        private static string APP_ID = "11358195";
        private static string API_KEY = "okyelBOfvR8gsHCMKM72gomY";
        private static string SECRET_KEY = "1rc3Atc4iRS0sUkFlE6e4GZCAaoAIsfQ";
        private static Ocr client = new Ocr(API_KEY, SECRET_KEY);
 
        public BaiDuClient()
        {
            client.Timeout = 60000;
        }
        /// <summary>
        /// 网络图片识别
        /// </summary>
        /// <param name="imgUrl"></param>
        public static WebImageUrlResponse WebImageUrl(string imgUrl)
        {
            var result = client.WebImageUrl(imgUrl);
            WebImageUrlResponse response = JSONUtil.JsonToObject<WebImageUrlResponse>(JSONUtil.ObjectToJson(result));
            response.IsSuccess = response.error_msg.IsNullOrEmpty() ? true : false;
            return response;
        }
    }
}