Пример #1
0
        public void GeneralBasic(string filePath)
        {
            var image = File.ReadAllBytes(filePath);

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

            // 图片url
            result = client.GeneralBasic("https://www.baidu.com/img/bd_logo1.png");
        }
Пример #2
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");
        }
Пример #3
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");
        }
Пример #4
0
        public static string GeneralBasic(Image tempImage)
        {
            var client = new Ocr.Ocr(Config.clientId, Config.clientSecret);

            var image = ImageHelper.ImageToBytes(tempImage, System.Drawing.Imaging.ImageFormat.Png);
            // 通用文字识别
            var result = client.GeneralBasic(image);

            return(result.ToJson());
        }