当前位置: 首页 > news >正文

C# PaddleOCR字符识别

1 安装Nuget

2 C#

using System;
using OpenCvSharp;
using Sdcb.PaddleOCR;
using Sdcb.PaddleOCR.Models.Local;
using Sdcb.PaddleOCR.Models;
using Sdcb.PaddleInference;


namespace ConsoleApp1
{
    public class MichaelOCR
    {
        string imagePath = "D:\\BUFFER\\VS\\Text\\ConsoleApp1\\2.jpg";

        public static int myAdd(int x, int y)
        {
            return x + y;

            Console.WriteLine("Hello World!");

        }


        public static string Poem()
        {
            return "heelo world" +
                "world----";
        }



        static void Main(string[] args)
        {
            string imagePath = "D:\\BUFFER\\VS\\Text\\ConsoleApp1\\2.jpg";
            FullOcrModel model = LocalFullModels.ChineseV3;
            Console.WriteLine(PaddleConfig.Version);


            using (PaddleOcrAll all = new PaddleOcrAll(model, PaddleDevice.Mkldnn())
            {
                AllowRotateDetection = true, /* 允许识别有角度的文字 */
                Enable180Classification = false, /* 允许识别旋转角度大于90度的文字 */
            })
            {
                // Load local file by following code:
                using (Mat src2 = Cv2.ImRead(imagePath))
                {
                    PaddleOcrResult result = all.Run(src2);
                    Console.WriteLine(result.Text);
                }
            }
            Console.WriteLine("Hello World!");
        }


        //下面是生成C# dll的

        //public static string Main(string imagePath)
        //{
        //    FullOcrModel model = LocalFullModels.ChineseV3;
        //    //Console.WriteLine(PaddleConfig.Version);


        //    using (PaddleOcrAll all = new PaddleOcrAll(model, PaddleDevice.Mkldnn())

        //    {
        //        AllowRotateDetection = true, /* 允许识别有角度的文字 */
        //        Enable180Classification = false, /* 允许识别旋转角度大于90度的文字 */
        //    })
        //    {

        //        // Load local file by following code:
        //        using (Mat src2 = Cv2.ImRead(imagePath))
        //        {
        //            PaddleOcrResult result = all.Run(src2);

        //            return result.Text;
        //            //Console.WriteLine(result.Text);
        //        }
        //    }
        //    //Console.WriteLine("Hello World!");
        //}
    }
}

3 官网资料

https://github.com/sdcb/PaddleSharp

相关文章:

  • Git 使用指南
  • OSPF-5 3类LSA SummaryLSA
  • MySQL---DDL(3.17)
  • 【工作记录】F12查看接口信息及postman中使用
  • 【鸿蒙开发】Hi3861学习笔记- 定时器中断
  • 谷歌生态变革!Google Play宣布上线PC游戏平台
  • python中多重继承和泛型 作为模板让子类实现具体业务逻辑
  • MySQL 基础学习文档
  • 李宏毅NLP-1-课程介绍
  • Excel导出工具类--复杂的excel功能导出(使用自定义注解导出)
  • C++实现线程安全的队列
  • 【Spring】第二弹:通过反射机制初步理解 IoC
  • C++从入门到入土(八)——多态的原理
  • 【GIS】重要技术3DGS
  • 改变一生的思维模型【12】笛卡尔思维模型
  • 【嵌入式学习】计算机组成原理-二进制存储基础
  • Spring Boot 的自动装配
  • 几种常见的激活函数解析
  • Vue学习笔记集--scoped组件
  • Elasticsearch面试题
  • 上海浦东机场1号、2号航站楼均推出国内出发安检24小时服务
  • 特朗普将启的中东行会如何影响伊美核谈判?专家分析
  • 警方通报“网约车司机偷拍女乘客”:已被行政拘留
  • 宇数科技王兴兴:第一桶金来自上海,欢迎上海的年轻人加入
  • 国际足联女子世界杯再次扩军,2031年起增至48支球队
  • 5天完成1000多万元交易额,“一张手机膜”畅销海内外的启示