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

相关推荐
Monkey_Xuan5 分钟前
C#中的引用传递和值传递
unity·c#
CreasyChan28 分钟前
C# LINQ 深度解析:优缺点与性能陷阱
unity·c#·游戏开发
毕设源码-朱学姐39 分钟前
【开题答辩全过程】以 基于Java的人体骨骼健康知识普及系统为例,包含答辩的问题和答案
java·开发语言
lly20240643 分钟前
Julia 函数
开发语言
sheji34161 小时前
【开题答辩全过程】以 基于JAVA的社团管理系统为例,包含答辩的问题和答案
java·开发语言
周杰伦_Jay1 小时前
【GOFrame】模块化框架与生产级实践
开发语言·gitlab·github
Simon席玉1 小时前
C++的命名重整
开发语言·c++·华为·harmonyos·arkts
chao1898441 小时前
MATLAB中的多重网格算法与计算流体动力学
开发语言·算法·matlab
木盏1 小时前
三维高斯的分裂
开发语言·python
精神小伙就是猛1 小时前
C# sealed密封 追本溯源
开发语言·c#