赞
踩
我这个方法是传入图片的字节数据
- public class VinoOcrHandler
- {
- public static async Task<string> handlerImgAsync(byte[] sampleImageData)
- {
-
- Settings.GlobalModelDirectory = ".\\Models";
-
- FullOcrModel model = await OnlineFullModels.ChineseV3.DownloadAsync();
-
-
- using (PaddleOcrAll all = new PaddleOcrAll(model)
- {
- AllowRotateDetection = true, /* 允许识别有角度的文字 */
- Enable180Classification = false, /* 允许识别旋转角度大于90度的文字 */
- })
- {
- // Load local file by following code:
- // using (Mat src2 = Cv2.ImRead(@"C:\test.jpg"))
- using (Mat src = Cv2.ImDecode(sampleImageData, ImreadModes.Color))
- {
- PaddleOcrResult result = all.Run(src);
- //Console.WriteLine("Detected all texts: \n" + result.Text);
- return result.Text;
- }
- }
- }
-
- }
Settings.GlobalModelDirectory = ".\\Models";
非常重要,在初次使用时,会将支持文件下载到这个目录,在发布的时候需要把这个目录拷贝到对应的目录下
下次使用就不会再下载了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。