Requirements: I have used PaddleOCR to recognize the text on the image before, but python has opened an http interface to call the interface through C# to obtain the result. How do I use C# for direct OCR text recognition? This article will use .NET 8 to call the PaddleOCR model to recognize graphics and text.
FastDeploy is an all-scenario, flexible, and extremely efficient AI inference deployment tool that supports cloud-edge deployment. Address:The hyperlink login is visible.
Review:
Download and install the FastDeploy library
First, download and install the FastDeploy library, the official provides some compiled ones, not provided, you need to compile it yourself, the compilation tutorial is as follows:
Taking Windows CPU deployment as an example, download address:The hyperlink login is visible.
Extract the package to the D:\temp folder and run the following command:
Compile the FastDeployCsharpSdk class library
Create a new .NET 8 library named FastDeployCsharpSdkThe hyperlink login is visible.Copy the source code to the bottom of this library and modify a few places:
int64_t -> Int64 Otherwise, an error is reported: Parameter 1: Unable to convert from "nint" to "string" new Mat(result_ptr); -> Mat.FromNativePointer(result_ptr); "fastdeploy.dll" -> "fastdeploy"
Meanwhile, the .csproj project references the following:
Successfully compile the library!
Download the PaddleOCR model
Download the ch_PP-OCRv3 model at:The hyperlink login is visible.Text box detection, direction classification model, text recognition, and dictionary files must be downloaded. thereintoThe encoding format of ppocr_keys_v1.txt has been modified from UTF-8 to ANSI formatYes, otherwise the recognition result will be garbled.
OCR recognition test
Create a new console project, reference the FastDeployCsharpSdk library, and test the code as follows:
After running, it will crash and you need to modify the FastDeployCsharpSdk class library\vision\ocr\model.csThe Predict method in the file will comment the following code:
Regarding calling Visualize.VisOcr exception exit, just don't use it, you already have a result set, you can implement it yourself, refer to the following:
Original:
The effect after recognition (due toOpenCvSharp4 adds Chinese garbled characters, everyone understands the meaning):
FastDeployCsharpSdk source code and finished product download:
Tourists, if you want to see the hidden content of this post, please Reply
Reference:
The hyperlink login is visible.
The hyperlink login is visible.
The hyperlink login is visible. |