Multithreading support
Contents
[
Hide
]
Aspose.OCR for Java allows you to limit the number of threads used by the recognition engine. This 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 setThreadsCount
method of the RecognitionSettings
class.
- If you specify
0
or do not set this parameter, the recognition engine will use all CPU cores. - If you specify
1
, recognition will be performed on the application’s main thread.
AsposeOCR api = new AsposeOCR();
// Limit recognition load to 2 threads
RecognitionSettings recognitionSettings = new RecognitionSettings();
recognitionSettings.setThreadsCount(2);
// Extract text from image
RecognitionResult result = api.RecognizePage("source.png", recognitionSettings);
// Show recognition result
System.out.println("Recognition result:\n" + result.recognitionText + "\n\n");