C# PaddleOCR字符识别

1 安装Nuget

2 C#

cs 复制代码
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

相关推荐
Rust研习社3 分钟前
添加依赖库时的 features 是什么?优雅实现编译期条件编译与模块化开发
开发语言·后端·rust
Tel1992530800412 分钟前
ENDAT2.2 协议信号转 SSI /BISS-C转换卡 ENDAT2.2 协议信号转DMC多摩川高速协议转换器 互转卡
c语言·开发语言·网络
Tiger_shl38 分钟前
C# 托管对象、非托管对象 讲解
开发语言·c#
HappyAcmen38 分钟前
10.常见报错排查与基础调试
开发语言·python
码农的神经元1 小时前
配电网智能决策平台:从风险感知到自愈控制的 Python 实现
开发语言·python
xlq223221 小时前
46.线程池
linux·开发语言
LF男男1 小时前
Action- C# 内置的委托类型
java·开发语言·c#
记录无知岁月1 小时前
【C/C++】头文件包含问题分析
c语言·开发语言·c++
神仙别闹1 小时前
基于Python实现(控制台)个人信息系统
开发语言·python