MultithreadedTesseract OCR
IronTesseract
2021 previously had a ReadMultithreaded
method to allow .NET developers to read images and PDFs more efficiently.
This is no longer needed in 2022. All IronOCR image processing and OCR reading operations are multithreaded and do not require the developer to use a special API.
IronTesseract
will automatically attempt to use all threads available on all cores and will consider responsiveness on the main / GUI thread elegantly.
How to Use Tesseract Multi-threading
- Install an OCR library to use Tesseract multi-threading
- Make an
IronTesseract
object. - Use
AddImage
to construct anOcrInput
and provide the image path into an object - Invoke all necessary methods for image processing.
- Use the
Read
method to read the text
using IronOcr; // Import the IronOcr namespace
class Program
{
static void Main()
{
// Initialize a new instance of IronTesseract
var Ocr = new IronTesseract();
// Create a new OcrInput object and add an image for OCR processing
using (var Input = new OcrInput())
{
// Add the image file path to the OcrInput object
Input.AddImage("path/to/your/image.png");
// Perform OCR on the input image to extract text
var Result = Ocr.Read(Input);
// Output the recognized text to the console
System.Console.WriteLine(Result.Text);
}
}
}
using IronOcr; // Import the IronOcr namespace
class Program
{
static void Main()
{
// Initialize a new instance of IronTesseract
var Ocr = new IronTesseract();
// Create a new OcrInput object and add an image for OCR processing
using (var Input = new OcrInput())
{
// Add the image file path to the OcrInput object
Input.AddImage("path/to/your/image.png");
// Perform OCR on the input image to extract text
var Result = Ocr.Read(Input);
// Output the recognized text to the console
System.Console.WriteLine(Result.Text);
}
}
}
Imports IronOcr ' Import the IronOcr namespace
Friend Class Program
Shared Sub Main()
' Initialize a new instance of IronTesseract
Dim Ocr = New IronTesseract()
' Create a new OcrInput object and add an image for OCR processing
Using Input = New OcrInput()
' Add the image file path to the OcrInput object
Input.AddImage("path/to/your/image.png")
' Perform OCR on the input image to extract text
Dim Result = Ocr.Read(Input)
' Output the recognized text to the console
System.Console.WriteLine(Result.Text)
End Using
End Sub
End Class
- The
IronTesseract
object is used to handle the OCR process. AddImage
is used to specify which image should be analyzed.- The
Read
method processes the image and outputs the result, which contains the recognized text. - The multithreading capabilities of IronOCR work automatically behind the scenes, maximizing CPU efficiency.