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

相关推荐
共享家952737 分钟前
QT 初识
开发语言·qt
共享家952742 分钟前
QT文件解析与乱码问题
开发语言·qt
王嘉俊9251 小时前
Qt 入门:构建跨平台 GUI 应用的强大框架
c语言·开发语言·c++·qt·入门·cpp
小白学大数据1 小时前
Python爬虫技术:招标信息抓取与关键词过滤 (1)
开发语言·爬虫·python
Irene19912 小时前
URLSearchParams :处理 URL 查询参数的接口
开发语言·前端·javascript
Dontla2 小时前
Web典型路由结构之Next.js (App Router, v13+) )(文件系统驱动的路由:File-based Routing)声明式路由:文件即路由
开发语言·前端·javascript
~无忧花开~2 小时前
JavaScript学习笔记(十七):ES6生成器函数详解
开发语言·前端·javascript·笔记·学习·es6·js
电商API_180079052472 小时前
获取淘宝商品视频API接口解析:通过商品链接url获取商品视频item_video
开发语言·爬虫·python·数据挖掘·数据分析
Pocker_Spades_A2 小时前
Python快速入门专业版(五十):Python异常处理:try-except语句(捕获单一与多个异常)
开发语言·python
-可乐加冰吗3 小时前
SuperMap iObjects .NET 11i 二次开发(十五)—— 类型转换之面转点
visualstudio·c#·.net