Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Aspose.OCR for .NET allows you to limit the number of threads used by the recognition engine. Decreasing the number of threads may slow down the recognition speed, but will allow you to reserve some resources for other processes such as the parallel image processing, web server, database management system, or background data analysis.
To set the number of threads, use ThreadsCount
parameter of the recognition settings:
Value | Behavior |
---|---|
Not set | The OCR engine will use all CPU cores/threads. |
0 | The OCR engine will use all CPU cores/threads. |
1 | OCR will be performed on the application’s main thread. |
More than 1 | The OCR engine will use the number of threads provided, but not more than the total number of CPU cores/threads. Read How it works for technical details. |
Multithreading works differently depending on the number of images in the recognition batch.
Applies to:
Aspose.OCR for .NET will use the provided number of threads to recognize blocks of text found on the image/page in parallel.
Applies to:
Each image from the batch is processed in one separate thread. If more than one thread is specified in ThreadsCount
parameter, images are recognized in parallel. The number of images processed simultaneously cannot exceed the value of ThreadsCount
recognition settings or the total number of CPU cores/threads (whichever is less). Image regions are always recognized one by one.
ThreadsCount
setting.
Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr();
// Add images to OcrInput object
Aspose.OCR.OcrInput input = new Aspose.OCR.OcrInput(Aspose.OCR.InputType.SingleImage);
input.Add("source1.png");
input.Add("source2.jpg");
input.Add("source3.png");
input.Add("source4.jpg");
// Limit resource usage to 2 threads
Aspose.OCR.RecognitionSettings recognitionSettings = new Aspose.OCR.RecognitionSettings();
recognitionSettings.ThreadsCount = 2;
// Recognize batch by 2 images in parallel
Aspose.OCR.OcrOutput results = recognitionEngine.Recognize(input, recognitionSettings);
foreach(Aspose.OCR.RecognitionResult result in results)
{
Console.WriteLine(result.RecognitionText);
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.