Skip to content

Commit ae4d906

Browse files
committed
use IronOCR
1 parent f470c89 commit ae4d906

File tree

9 files changed

+13
-22
lines changed

9 files changed

+13
-22
lines changed

Tests/NetAutoGUI.Windows.IntegrationTests/NetAutoGUI.Windows.IntegrationTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<RootNamespace>NetAutoGUI.Windows.UnitTests</RootNamespace>
88
</PropertyGroup>
99
<ItemGroup>
10+
<PackageReference Include="IronOcr" Version="2025.6.4"/>
1011
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
1112
<PackageReference Include="SkiaSharp" Version="3.116.1" />
12-
<PackageReference Include="Tesseract" Version="5.2.0"/>
1313
<PackageReference Include="xunit" Version="2.4.1" />
1414
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

Tests/NetAutoGUI.Windows.IntegrationTests/TestHelpers.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using Tesseract;
4-
1+
using IronOcr;
52
namespace NetAutoGUI.Windows.UnitTests
63
{
74
internal class TestHelpers
@@ -40,11 +37,17 @@ public static string FindFile(string root, string fileName)
4037

4138
public static string RecognizeText(byte[] imageBytes)
4239
{
43-
using var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default);
44-
using var img = Pix.LoadFromMemory(imageBytes);
45-
using var page = engine.Process(img);
46-
var text = page.GetText();
47-
return text;
40+
//30 days trial license key for IronOCR only for testing purposes.
41+
License.LicenseKey =
42+
"IRONSUITE.YANGZHONGKE8.GMAIL.COM.22106-90FE0AAA3C-OD3XZ-PVWAV2FNGYIZ-YLPG6NXOE4GJ-P7DROHHD4LHA-N3C7WKRH3RXX-4OPJZH7DSLIS-HZMNQHLROTGX-4IXOUV-TKMJDR7O4VWPUA-DEPLOYMENT.TRIAL-ALR7LC.TRIAL.EXPIRES.20.JUL.2025";
43+
44+
var ocr = new IronTesseract();
45+
using var ocrInput = new OcrInput();
46+
ocrInput.LoadImage(imageBytes);
47+
var ocrResult = ocr.Read(ocrInput);
48+
return ocrResult.Text;
49+
50+
//todo: change to Azure OCR, and put credentials in environment variables to avoid hardcoding
4851
}
4952
}
5053
}

Tests/NetAutoGUI.Windows.IntegrationTests/UIElementTests/UIElementShould.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Xunit;
22
using FluentAssertions;
33
using System.Diagnostics;
4-
using Tesseract;
54

65
namespace NetAutoGUI.Windows.UnitTests.UIElementTests;
76

Tests/NetAutoGUI.Windows.IntegrationTests/tessdata/Configs/bazzar

Lines changed: 0 additions & 4 deletions
This file was deleted.
-22.4 MB
Binary file not shown.

Tests/NetAutoGUI.Windows.IntegrationTests/tessdata/eng.user-patterns

Lines changed: 0 additions & 2 deletions
This file was deleted.

Tests/NetAutoGUI.Windows.IntegrationTests/tessdata/eng.user-words

Lines changed: 0 additions & 5 deletions
This file was deleted.
-10.1 MB
Binary file not shown.
-572 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)