Beispiel #1
0
        private static JObject JudgeMethod(ApiVersion apiVersion, byte[] image)
        {
            JObject result;

            switch (apiVersion)
            {
            case ApiVersion.GeneralBasic:
                result = client.GeneralBasic(image);
                break;

            case ApiVersion.General:
                result = client.General(image);
                break;

            case ApiVersion.AccurateBasic:
                result = client.AccurateBasic(image);
                break;

            case ApiVersion.Accurate:
                result = client.Accurate(image);
                break;

            case ApiVersion.Numbers:
                result = client.Numbers(image);
                break;

            default:
                result = null;
                break;
            }
            return(result);
        }
Beispiel #2
0
        public JObject Number(string path)
        {
            string apikey    = "hUqtyvI4ip03GS8ehcpI3hRX";
            string secretkey = "DIM7drbNHoGlhLXjD7AMf9uD3bYlSNhN";
            var    client    = new Baidu.Aip.Ocr.Ocr(apikey, secretkey);

            client.Timeout = 60000;  // 修改超时时间
            var image   = File.ReadAllBytes(path);
            var options = new Dictionary <string, object> {
                //{"language_type", "CHN_ENG"},
                { "detect_direction", "true" },
                //{"detect_language", "true"},
                //{"probability", "true"}
            };
            // 数字识别
            var result = client.Numbers(image, options);

            return(result);
        }