-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from iron-software/ocr-benchmark
Add: OCR benchmark between IronOcr and Aspose
- Loading branch information
Showing
20 changed files
with
275 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using System.Reflection; | ||
|
||
namespace IronBenchmarks.OcrLibs.Benchmarks | ||
{ | ||
public abstract class BenchmarkBase | ||
{ | ||
public BenchmarkBase() | ||
{ | ||
SetupLicenses(); | ||
EnsureResultsFolderExists(); | ||
} | ||
|
||
public static void SetupLicenses() | ||
{ | ||
IConfigurationBuilder builder = new ConfigurationBuilder() | ||
.AddUserSecrets(Assembly.GetExecutingAssembly(), true); | ||
IConfigurationRoot configuration = builder.Build(); | ||
IConfigurationSection appConfig = configuration.GetSection("AppConfig"); | ||
string licenseKeyIronOcr = appConfig["LicenseKeyIronOcr"]; | ||
|
||
IronOcr.License.LicenseKey = licenseKeyIronOcr; | ||
} | ||
|
||
public static void EnsureResultsFolderExists() | ||
{ | ||
string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); | ||
string reportsFolder = Path.Combine(path ?? "", "Results"); | ||
|
||
if (!Directory.Exists(reportsFolder)) | ||
{ | ||
_ = Directory.CreateDirectory(reportsFolder); | ||
} | ||
} | ||
|
||
public abstract void Iron_Ocr(); | ||
|
||
public abstract void Aspose_Ocr(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using IronOcr; | ||
|
||
namespace IronBenchmarks.OcrLibs.Benchmarks | ||
{ | ||
[ShortRunJob] | ||
[MemoryDiagnoser] | ||
public class Read12MBPdf : BenchmarkBase | ||
{ | ||
[Benchmark] | ||
public override void Aspose_Ocr() | ||
{ | ||
Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr(); | ||
var source = new Aspose.OCR.OcrInput(Aspose.OCR.InputType.PDF); | ||
source.Add(@"TestPdfs\linux_commands.pdf"); | ||
|
||
List<Aspose.OCR.RecognitionResult> results = recognitionEngine.Recognize(source); | ||
|
||
foreach (Aspose.OCR.RecognitionResult result in results) | ||
{ | ||
_ = result.RecognitionText; | ||
} | ||
} | ||
|
||
[Benchmark] | ||
public override void Iron_Ocr() | ||
{ | ||
var input = new OcrInput(); | ||
input.LoadPdf("TestPdfs/linux_commands.pdf"); | ||
var ocr = new IronTesseract(); | ||
OcrResult result = ocr.Read(input); | ||
_ = result.Text; | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
IronBenchmarks.OcrLibs/Benchmarks/ReadAndRenderSearchablePdf.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using IronOcr; | ||
|
||
namespace IronBenchmarks.OcrLibs.Benchmarks | ||
{ | ||
[ShortRunJob] | ||
[MemoryDiagnoser] | ||
public class ReadAndRenderSearchablePdf : BenchmarkBase | ||
{ | ||
[Benchmark] | ||
public override void Aspose_Ocr() | ||
{ | ||
Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr(); | ||
var source = new Aspose.OCR.OcrInput(Aspose.OCR.InputType.TIFF); | ||
source.Add(@"TestMultiPageImages\test_dw_10.tif"); | ||
|
||
List<Aspose.OCR.RecognitionResult> results = recognitionEngine.Recognize(source); | ||
|
||
foreach (Aspose.OCR.RecognitionResult result in results) | ||
{ | ||
_ = result.RecognitionText; | ||
} | ||
|
||
Aspose.OCR.AsposeOcr.SaveMultipageDocument("aspose_large_tiff.pdf", Aspose.OCR.SaveFormat.Pdf, results); | ||
} | ||
|
||
[Benchmark] | ||
public override void Iron_Ocr() | ||
{ | ||
var input = new IronOcr.OcrInput(); | ||
input.LoadImage(@"TestMultiPageImages\test_dw_10.tif"); | ||
|
||
var ironTesseract = new IronTesseract(); | ||
OcrResult result = ironTesseract.Read(input); | ||
|
||
foreach (OcrResult.Page page in result.Pages) | ||
{ | ||
_ = page.Text; | ||
} | ||
|
||
result.SaveAsSearchablePdf("iron_large_tiff.pdf"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using IronOcr; | ||
|
||
namespace IronBenchmarks.OcrLibs.Benchmarks | ||
{ | ||
[ShortRunJob] | ||
[MemoryDiagnoser] | ||
public class ReadImage : BenchmarkBase | ||
{ | ||
[Benchmark] | ||
public override void Aspose_Ocr() | ||
{ | ||
Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr(); | ||
var source = new Aspose.OCR.OcrInput(Aspose.OCR.InputType.SingleImage); | ||
source.Add(@"TestImages\stock_gs200.jpg"); | ||
|
||
List<Aspose.OCR.RecognitionResult> results = recognitionEngine.Recognize(source); | ||
|
||
foreach (Aspose.OCR.RecognitionResult result in results) | ||
{ | ||
_ = result.RecognitionText; | ||
} | ||
} | ||
|
||
[Benchmark] | ||
public override void Iron_Ocr() | ||
{ | ||
var input = new IronOcr.OcrInput(); | ||
input.LoadImage(@"TestImages\stock_gs200.jpg"); | ||
|
||
var ironTesseract = new IronTesseract(); | ||
OcrResult result = ironTesseract.Read(input); | ||
|
||
foreach (OcrResult.Page page in result.Pages) | ||
{ | ||
_ = page.Text; | ||
} | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
IronBenchmarks.OcrLibs/Benchmarks/ReadMultipleDocuments.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using IronOcr; | ||
|
||
namespace IronBenchmarks.OcrLibs.Benchmarks | ||
{ | ||
[ShortRunJob] | ||
[MemoryDiagnoser] | ||
public class ReadMultipleDocuments : BenchmarkBase | ||
{ | ||
[Benchmark] | ||
public override void Aspose_Ocr() | ||
{ | ||
Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr(); | ||
var source = new Aspose.OCR.OcrInput(Aspose.OCR.InputType.Directory); | ||
source.Add("TestImages"); | ||
|
||
List<Aspose.OCR.RecognitionResult> results = recognitionEngine.Recognize(source); | ||
|
||
foreach (Aspose.OCR.RecognitionResult result in results) | ||
{ | ||
_ = result.RecognitionText; | ||
} | ||
} | ||
|
||
[Benchmark] | ||
public override void Iron_Ocr() | ||
{ | ||
var input = new IronOcr.OcrInput(); | ||
input.LoadImage(@"TestImages\001_20221121000002_S2123457_EL37.tiff"); | ||
input.LoadImage(@"TestImages\stock_gs200.jpg"); | ||
|
||
var ironTesseract = new IronTesseract(); | ||
OcrResult result = ironTesseract.Read(input); | ||
|
||
foreach (OcrResult.Page page in result.Pages) | ||
{ | ||
_ = page.Text; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Aspose.OCR" Version="24.12.0" /> | ||
<PackageReference Include="IronOcr" Version="2025.2.2" /> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="TestImages\001_20221121000002_S2123457_EL37.tiff"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="TestImages\stock_gs200.jpg"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="TestMultiPageImages\test_dw_10.tif"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="TestPdfs\example.pdf"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="TestPdfs\linux_commands.pdf"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
Binary file added
BIN
+1.32 MB
IronBenchmarks.OcrLibs/TestImages/001_20221121000002_S2123457_EL37.tiff
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.