sdcb / PaddleSharp

.NET/C# binding for Baidu paddle inference library and PaddleOCR
Apache License 2.0
1.04k stars 198 forks source link

Can this code example run on xamarin android #68

Open smetronic opened 12 months ago

smetronic commented 12 months ago

Hi,

i want to know if the below example will work on Xamarin android

Windows(Local model): Detection and Recognition(All) Install NuGet Packages:

Sdcb.PaddleInference Sdcb.PaddleOCR Sdcb.PaddleOCR.Models.Local Sdcb.PaddleInference.runtime.win64.mkl OpenCvSharp4.runtime.win Using following C# code to get result:

FullOcrModel model = LocalFullModels.ChineseV3;

byte[] sampleImageData; string sampleImageUrl = @"https://www.tp-link.com.cn/content/images2017/gallery/4288_1920.jpg"; using (HttpClient http = new HttpClient()) { Console.WriteLine("Download sample image from: " + sampleImageUrl); sampleImageData = await http.GetByteArrayAsync(sampleImageUrl); }

using (PaddleOcrAll all = new PaddleOcrAll(model, PaddleDevice.Mkldnn()) { 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); foreach (PaddleOcrResultRegion region in result.Regions) { Console.WriteLine($"Text: {region.Text}, Score: {region.Score}, RectCenter: {region.Rect.Center}, RectSize: {region.Rect.Size}, Angle: {region.Rect.Angle}"); } } }

sdcb commented 11 months ago

it will not work, because I didn't compile android arm64's paddle_inference_c library.

ertan2002 commented 4 months ago

@sdcb Is there anyplan for xamarin.forms? It would be great if we could use it in the mobile platforms