当前位置:网站首页>C test calls the paddlesharp module to recognize pictures and words
C test calls the paddlesharp module to recognize pictures and words
2022-04-23 05:19:00 【gc_ two thousand two hundred and ninety-nine】
PaddleSharp yes PaddleInference C API Of C# Packaged version , Support in Windows(x64)、NVIDIA GPU and Linux(Ubuntu-20.04 x64) Use in .PaddleShare It mainly includes PaddleOCR and PaddleDetection, among PaddleOCR Support 14 Words in different languages , Support the recognition of text with multiple rotation angles ,PaddleDetection Support PPYolo Check the model and PicoDet Model ( About PaddleSharp See references for a detailed introduction of 1).
Can pass NuGet Manager Download PaddleSharp Related to the package , At first, I thought the package name was based on PaddleSharp start , It turns out that NuGet I can't find anything in the manager , stay GitHub Of PaddleSharp Home page , Lists PaddleSharp Related package list ( As shown in the figure below ), All of them Sdcb start , These bags are in NuGet You can search and install in the manager .
This paper mainly tests C# call PaddleSharp Of PaddleOCR Carry out picture and character recognition , reference 2 Of PaddleOCR The instructions for use list the packages to be installed , stay VS Install the following packages in ( At first, I didn't want to install so many , Just install Sdcb.PaddleOCR, Although the program can be compiled through , It can also run , However, in the process of recognizing the picture and text, it will always be prompted that some of the items in the drop-down package list are missing , Finally, you need to recognize pictures and words normally , You still need to pack all the following bags ).
Sdcb.PaddleInference
Sdcb.PaddleInference.runtime.win64.mkl
Sdcb.PaddleOCR
Sdcb.PaddleOCR.KnownModels
OpenCvSharp4
OpenCvSharp4.runtime.win
Refer to references 2 Function test the sample code in ( Please check the detailed code in the literature , I won't post it here ), The code sequence is mainly to load the model -> Loading pictures -> Identifying text -> Show results . Here we mainly talk about and use PaddleOCRSharp The difference between , Because the tests are simple , What I said is relatively simple .
PaddleOCRSharp and PaddleSharp Are written in other languages ocr Functional C# Packaged version , by comparison PaddleOCRSharp The encapsulation is simpler . adopt NuGet install PaddleOCRSharp, The dependent files will be automatically downloaded and associated to the project , and PaddleSharp You need to manually install all required packages .
PaddleOCRSharp Execute the required model, download it synchronously when installing the package and associate it with the project , and PaddleSharp, From the test code , It defaults from C:\Users\HP\AppData\Roaming\paddleocr-models\ppocr-v2 Read the required model in the folder , If it doesn't exist , Downloaded from the Internet in real time ,OCRModel The download path of various models is recorded in the object ( In the process of actual implementation , Due to the average download speed , Directly use Xunlei to manually download and copy to the corresponding folder ).
OCRModel model = KnownOCRModel.PPOcrV2;
await model.EnsureAll();
And when recognizing pictures and words ,PaddleOCRSharp It encapsulates , Just specify the image path in the program 、 Picture byte array or Image Object can , and PaddleSharp Functions that recognize pictures ,PaddleOcrAll.Run, You need to convert the picture to the specified Mat object .
PaddleSharp The results of recognition include two types ,PaddleOcrResult.Text Combine all the recognized characters into one string ,PaddleOcrResult.Regions Save each recognized text block in .
The text block type is PaddleOcrResultRegion, among Rect( The type is RotatedRect) Save rectangle position information containing text ( The rectangle may be non horizontal or vertical ).RotatedRect The definition of class is shown in the figure below , among BoundingRect Function returns a rectangle containing a rotation rectangle . Take the picture below as an example PaddleOcrResultRegion.Rect Is a red rectangle , and BoundingRect() Returns a purple rectangle . meanwhile RotatedRect Class Points Function returns the position information of the four corners of the rotating rectangle , You can draw a rotating rectangle containing text by drawing lines , It's simpler .
Finally, the recognition effect of the test image is listed ( Use the sample code in the references , The text blocks are basically circled out , But some of the contents are not correctly identified ).
reference
[1]https://github.com/sdcb/PaddleSharp
[2]https://github.com/sdcb/PaddleSharp/blob/master/docs/ocr.md
Test picture source
[1]https://baijiahao.baidu.com/s?id=1676249081188736513&wfr=spider&for=pc
[2]https://www.xjauto.net/html/cheping/202105/69508.html
[3]https://item.jd.com/10041422363991.html?openbpab=dontwritecookie&uabt=92_16_21&cu=true&utm_source=image.baidu.com&utm_medium=tuiguang&utm_campaign=t_1003608409_&utm_term=1a1dd3a2f0b24eaab2325b16b12d3d8d
[4]http://news.sohu.com/a/524033869_121124363
版权声明
本文为[gc_ two thousand two hundred and ninety-nine]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230516277530.html
边栏推荐
- Logrus set log format and output function name
- Using MySQL with Oracle
- How to add beautiful code blocks in word | a very complete method to sort out and compare
- Acid of MySQL transaction
- The source of anxiety of graduating college students looking for technology development jobs
- Interview summary
- Study notes: unity customsrp-13-colorgrading
- Deep learning notes - data expansion
- 即将毕业的大学生找技术开发工作的焦虑根源
- MySQL views the SQL statement details executed by the optimizer
猜你喜欢
Publish your own wheel - pypi packaging upload practice
JS array common methods
我这位老程序员对时代危险和机遇的一点感悟?
Basic concepts of multithreading (concurrency and parallelism, threads and processes) and entry cases
Routing parameters
Flip coin (Blue Bridge Cup)
Live delivery form template - automatically display pictures - automatically associate series products
项目经理值得一试的思维方式:项目成功方程式
Kanban Quick Start Guide
Let the LAN group use the remote device
随机推荐
Study notes: unity customsrp-13-colorgrading
Minimum spanning tree -- unblocked project hdu1863
At pgconf Asia Chinese technology forum, listen to Tencent cloud experts' in-depth understanding of database technology
低代码和无代码的注意事项
In aggregated query without group by, expression 1 of select list contains nonaggregated column
The 2021 more reading report was released, and the book consumption potential of post-95 and Post-00 rose
Mariadb的半同步复制
When is it appropriate for automated testing? (bottom)
4 most common automated test challenges and Countermeasures
[2021] Spatio-Temporal Graph Contrastive Learning
MySQL slow query
Locks and transactions in MySQL
Five key technologies to improve the devsecops framework
Three 之 three.js (webgl)模型的删除/场景的清空/内存的释放 的简单整理
Three 之 three.js (webgl)简单实现根据点绘制线/弧线(基于LineGeometry / Line2 / LineMaterial,绘制两点基于圆心的弧线段)
Three 之 three.js (webgl)旋转属性函数的简单整理,以及基于此实现绕轴旋转的简单案例
The applet calls the function of scanning QR code and jumps to the path specified by QR code
Graphics.FromImage报错“Graphics object cannot be created from an image that has an indexed pixel ...”
Chapter II project scope management of information system project manager summary
Simple application of parallel search set (red alarm)