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

相关推荐
爱吃小白兔的猫18 分钟前
LPA算法详解:一种近线性时间的图社区发现方法
开发语言·php
香蕉鼠片1 小时前
算法过程中不会的
开发语言·c++
阿旭超级学得完1 小时前
C++11包装器(function和bind)
java·开发语言·c++·算法·哈希算法·散列表
輕華1 小时前
uv工具详解——Python包与项目管理器完全指南
开发语言·python·uv
念何架构之路2 小时前
Go语言常见并发模式
开发语言·后端·golang
祀爱2 小时前
Asp.net core+ Layui 项目中编辑按钮传递数据的方法
前端·c#·asp.net·layui
磊 子2 小时前
多态类原理+四种类型转换+异常处理
开发语言·c++·算法
脆皮炸鸡7552 小时前
库制作与原理~动态链接
linux·开发语言·经验分享·笔记·学习方法