Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.AccessViolationException:“Attempted to read or write protected memory. This is often an indication that other memory is corrupt.” #34

Open
upoorcake opened this issue Dec 14, 2024 · 3 comments

Comments

@upoorcake
Copy link

using OpenCvSharp;
using Sdcb.OpenVINO.PaddleOCR.Models.Online;
using Sdcb.OpenVINO.PaddleOCR.Models;
using Sdcb.OpenVINO.PaddleOCR;
using System.Diagnostics;
using System;

FullOcrModel model = await OnlineFullModels.ChineseV4.DownloadAsync();

using (PaddleOcrAll all = new(model)
{
AllowRotateDetection = true,
Enable180Classification = true,
})
{
while (true) {
var src = Cv2.ImRead("M:/CSharp/20241214_235857880.png");
// Load local file by following code:
// using (Mat src2 = Cv2.ImRead(@"C:\test.jpg"))
Stopwatch sw = Stopwatch.StartNew();
PaddleOcrResult result = all.Run(src);
Console.WriteLine($"elapsed={sw.ElapsedMilliseconds} ms");
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}");
}
Thread.Sleep(1);
}

}

用你给出的这段代码加了一个while测试出现异常 PaddleOcrResult result = all.Run(src);报错System.AccessViolationException:“Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”

@upoorcake
Copy link
Author

手动进行垃圾收集好像没出现了,但不确定

@upoorcake
Copy link
Author

只是持续循环的时间更长了,还是会出现的

@upoorcake
Copy link
Author

opencvsharp 4.10版本的问题,换其他版本可以解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant