C#PaddleOCRSharp使用

 

复制代码
using PaddleOCRSharp;

namespace PaddleOCRSharpDemo
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //中英文模型V3模型
            OCRModelConfig config = null;

            //OCR参数
            OCRParameter oCRParameter = new OCRParameter();
            oCRParameter.cpu_math_library_num_threads = 6;//预测并发线程数
            oCRParameter.enable_mkldnn = true;//是否使用mkldnn模型
            oCRParameter.cls = false; //是否执行文字方向分类
            oCRParameter.use_angle_cls = false;//是否开启方向检测
            oCRParameter.det_db_score_mode = true;//是否使用多段线,即文字区域是用多段线还是用矩形,
            oCRParameter.det_db_unclip_ratio = 1.6f;
            oCRParameter.max_side_len = 2000;

            //初始化OCR引擎
            var engine = new PaddleOCREngine(config, oCRParameter);


            var imagebyte = File.ReadAllBytes("1.jpg");
            OCRResult ocrResult = engine.DetectText(imagebyte);

            // 输出所有
            //Console.WriteLine(ocrResult.Text);

            // 按行输出
            var blocks = ocrResult.TextBlocks;
            foreach (var line in blocks)
            {
                Console.WriteLine(line.Text);
            }
        }
    }
}
复制代码

 

https://www.yingtianit.com/

 

posted @   CHHC  阅读(39)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示