Пример #1
0
        public static string GeneralBasic(string path)
        {
            string resultStr = "";
            var    client    = new Ocr.Ocr(api, key);
            var    image     = File.ReadAllBytes(path);

            // 通用文字识别
            var result = client.GeneralBasic(image);

            //var result = client.Accurate(image);
            //var result = client.General(image);
            if (result.Property("words_result") == null || result.Property("words_result").ToString() == "")
            {
                Console.WriteLine("键值key不存在!");
                return(result.ToString());
            }
            else
            {
                var words = result["words_result"];
                foreach (var item in words)
                {
                    resultStr += item["words"];
                }
            }
            return(resultStr);
            // 图片url
            //result = client.GeneralBasic("https://www.baidu.com/img/bd_logo1.png");
        }
Пример #2
0
        public static void AccurateWithLocation()
        {
            var client = new Ocr.Ocr(Config.clientId, Config.clientSecret);
            var image  = File.ReadAllBytes("图片文件路径");

            // 高精度识别(带位置信息)
            var result = client.AccurateWithLocation(image);
        }
Пример #3
0
        public static void AccurateWithLocation(string path)
        {
            var client = new Ocr.Ocr(api, key);
            var image  = File.ReadAllBytes(path);

            // 高精度识别(带位置信息)
            //var result = client.AccurateWithLocation(image);
        }
Пример #4
0
        public static void Accurate(string path)
        {
            var client = new Ocr.Ocr(api, key);
            var image  = File.ReadAllBytes(path);

            // 高精度识别
            var result = client.Accurate(image);
        }
Пример #5
0
        public static void WebImage(string path)
        {
            var client = new Ocr.Ocr(api, key);
            var image  = File.ReadAllBytes(path);

            // 网图识别
            var result = client.WebImage(image, null);
        }
Пример #6
0
        public static void GeneralWithLocatin(string path)
        {
            var client = new Ocr.Ocr(api, key);
            var image  = File.ReadAllBytes(path);

            // 带位置版本
            //var result = client.GeneralWithLocatin(image, null);
        }
Пример #7
0
        public static void BankCard(string path)
        {
            var client = new Ocr.Ocr(api, key);
            var image  = File.ReadAllBytes(path);

            // 银行卡识别
            //var result = client.BankCard(image);
        }
Пример #8
0
        public static void AccurateWithLocation()
        {
            var client = new Ocr.Ocr("Api Key", "Secret Key");
            var image  = File.ReadAllBytes("图片文件路径");

            // 高精度识别(带位置信息)
            var result = client.AccurateWithLocation(image);
        }
Пример #9
0
        public static void WebImage()
        {
            var client = new Ocr.Ocr("Api Key", "Secret Key");
            var image  = File.ReadAllBytes("图片文件路径");

            // 网图识别
            var result = client.WebImage(image, null);
        }
Пример #10
0
        public static void GeneralWithLocatin()
        {
            var client = new Ocr.Ocr(Config.clientId, Config.clientSecret);
            var image  = File.ReadAllBytes("图片文件路径");

            // 带位置版本
            var result = client.GeneralWithLocatin(image, null);
        }
Пример #11
0
        public static void WebImage()
        {
            var client = new Ocr.Ocr(Config.clientId, Config.clientSecret);
            var image  = File.ReadAllBytes("图片文件路径");

            // 网图识别
            var result = client.WebImage(image, null);
        }
Пример #12
0
        /// <summary>
        /// 基础
        /// </summary>
        /// <param name="tempImage"></param>
        /// <returns></returns>
        public static string DrivingLicense(Image tempImage)
        {
            var client = new Ocr.Ocr(Config.clientId, Config.clientSecret);
            var image  = ImageHelper.ImageToBytes(tempImage, System.Drawing.Imaging.ImageFormat.Png);
            var result = client.DrivingLicense(image);

            return(result.ToString());
        }
Пример #13
0
        public static void GeneralEnhanced(string path)
        {
            var client = new Ocr.Ocr(api, key);
            var image  = File.ReadAllBytes(path);

            // 带生僻字版
            var result = client.GeneralEnhanced(image);
        }
Пример #14
0
        public static void BankCard()
        {
            var client = new Ocr.Ocr("Api Key", "Secret Key");
            var image  = File.ReadAllBytes("图片文件路径");

            // 银行卡识别
            var result = client.BankCard(image);
        }
Пример #15
0
        public static void GeneralWithLocatin()
        {
            var client = new Ocr.Ocr("Api Key", "Secret Key");
            var image  = File.ReadAllBytes("图片文件路径");

            // 带位置版本
            var result = client.GeneralWithLocatin(image, null);
        }
Пример #16
0
        public static void GeneralEnhanced()
        {
            var client = new Ocr.Ocr("Api Key", "Secret Key");
            var image  = File.ReadAllBytes("图片文件路径");

            // 带生僻字版
            var result = client.GeneralEnhanced(image);
        }
Пример #17
0
        /// <summary>
        /// 网络图片识别,适合网络图片文字识别用于识别一些网络上背景复杂,特殊字体的文字。
        /// </summary>
        /// <param name="tempImage"></param>
        /// <returns>返回 json 字符串</returns>
        public static string WebImage(Image tempImage)
        {
            var    client = new Ocr.Ocr(Config.clientId, Config.clientSecret);
            var    image  = ImageHelper.ImageToBytes(tempImage, System.Drawing.Imaging.ImageFormat.Png);
            string result = client.WebImage(image, null).ToString();

            return(result);
        }
Пример #18
0
        public static void GeneralEnhanced()
        {
            var client = new Ocr.Ocr(Config.clientId, Config.clientSecret);
            var image  = File.ReadAllBytes("图片文件路径");

            // 带生僻字版
            var result = client.GeneralEnhanced(image);
        }
Пример #19
0
        public static void BankCard(string imagePath)
        {
            var client = new Ocr.Ocr(Config.clientId, Config.clientSecret);
            var image  = File.ReadAllBytes(imagePath);

            // 银行卡识别
            var result = client.BankCard(image);
        }
Пример #20
0
        public static string GeneralEnhanced(Image tempImage)
        {
            var client = new Ocr.Ocr(Config.clientId, Config.clientSecret);
            var image  = ImageHelper.ImageToBytes(tempImage, System.Drawing.Imaging.ImageFormat.Png);

            // 带生僻字版
            var result = client.GeneralEnhanced(image);

            return(result.ToJson());
        }
Пример #21
0
 public static void Receipt()
 {
     var client  = new Ocr.Ocr(Config.clientId, Config.clientSecret);
     var image   = File.ReadAllBytes("图片文件路径");
     var options = new Dictionary <string, object>
     {
         { "recognize_granularity", "small" } // 定位单字符位置
     };
     var result = client.Receipt(image, options);
 }
Пример #22
0
 public static void Receipt(string path)
 {
     var client  = new Ocr.Ocr(api, key);
     var image   = File.ReadAllBytes(path);
     var options = new Dictionary <string, object>
     {
         { "recognize_granularity", "small" } // 定位单字符位置
     };
     var result = client.Receipt(image, options);
 }
Пример #23
0
        public static string Accurate(Image tempImage)
        {
            var client = new Ocr.Ocr(Config.clientId, Config.clientSecret);
            var image  = ImageHelper.ImageToBytes(tempImage, System.Drawing.Imaging.ImageFormat.Png);

            // 高精度识别
            var result = client.Accurate(image);

            return(result.ToJson());
        }
Пример #24
0
        public static void GeneralBasic()
        {
            var client = new Ocr.Ocr(Config.clientId, Config.clientSecret);
            var image  = File.ReadAllBytes("图片文件路径");

            // 通用文字识别
            var result = client.GeneralBasic(image);

            // 图片url
            result = client.GeneralBasic("https://www.baidu.com/img/bd_logo1.png");
        }
Пример #25
0
        public static void Idcard(string path)
        {
            var client = new Ocr.Ocr(api, key);
            var image  = File.ReadAllBytes(path);

            var options = new Dictionary <string, object>
            {
                { "detect_direction", "true" } // 检测方向
            };
            // 身份证正面识别
            //var result = client.IdCardFront(image, options);
            // 身份证背面识别
            //result = client.IdCardBack(image);
        }
Пример #26
0
        public static void Idcard()
        {
            var client = new Ocr.Ocr(Config.clientId, Config.clientSecret);
            var image  = File.ReadAllBytes("图片文件路径");

            var options = new Dictionary <string, object>
            {
                { "detect_direction", "true" } // 检测方向
            };
            // 身份证正面识别
            var result = client.IdCardFront(image, options);

            // 身份证背面识别
            result = client.IdCardBack(image);
        }
Пример #27
0
        /// <summary>
        /// 网络图片识别,适合网络图片文字识别用于识别一些网络上背景复杂,特殊字体的文字。
        /// </summary>
        /// <param name="tempImage"></param>
        public static APIBaseModel <DrivingLicenseModel> GetWebImage(Image tempImage)
        {
            APIBaseModel <DrivingLicenseModel> tempModel = new APIBaseModel <DrivingLicenseModel>();

            tempModel.contextModel = new DrivingLicenseModel();

            var    client = new Ocr.Ocr(Config.clientId, Config.clientSecret);
            var    image  = ImageHelper.ImageToBytes(tempImage, System.Drawing.Imaging.ImageFormat.Png);
            string result = client.WebImage(image, null).ToString();

            if (result.Contains("\"error_code\""))//说明异常
            {
                tempModel.state = false;
                tempModel.contextModel.errorTypeModel = Json.ToObject <ErrorTypeModel>(result);
                tempModel.errorMsg = tempModel.contextModel.errorTypeModel.error_discription = OCR_CharacterRecognitionErrorType.GetErrorCodeToDescription(tempModel.contextModel.errorTypeModel.error_code);
            }
            else
            {
                tempModel.state = true;
                tempModel.contextModel.successModel = Json.ToObject <DrivingLicenseSuessResultModel>(result);
            }
            return(tempModel);
        }
Пример #28
0
 public static void BusinessLicense(string path)
 {
     var client = new Ocr.Ocr(api, key);
     var image  = File.ReadAllBytes(path);
     var result = client.BusinessLicense(image);
 }
Пример #29
0
 public static void VehicleLicense()
 {
     var client = new Ocr.Ocr("Api Key", "Secret Key");
     var image  = File.ReadAllBytes("图片文件路径");
     var result = client.VehicleLicense(image);
 }
Пример #30
0
 public static void BusinessLicense()
 {
     var client = new Ocr.Ocr(Config.clientId, Config.clientSecret);
     var image  = File.ReadAllBytes("图片文件路径");
     var result = client.BusinessLicense(image);
 }