Recognize single line
If an image contains a single line of text, it can be recognized in the fastest possible mode, without automated corrections, areas detection, and other resource-consuming steps. To extract text from such images, use recognize_lines
method or enable recognize_single_line
property in recognition settings.
This method takes OcrInput
object and optional recognition settings.
Recognition results are returned as a OcrOutput
object, that allow you to perform advanced manipulations with recognition results, including automatic spelling correction and saving results in various formats.
Example
The following code example shows how to extract text from a single-line image:
# Instantiate Aspose.OCR API
api = AsposeOcr()
# Add image to the recognition batch
input = OcrInput(InputType.SINGLE_IMAGE)
input.add("source1.png")
input.add("source2.png")
# Recognize images
results = api.recognize_lines(input)
# Print recognition result
for result in results:
print(result.recognition_text)
Performance impact
This method is about 7 times faster than normal OCR and is highly recommended for batch processing large numbers of very simple images.
Drawbacks
This method only works for images which contain a single line of text! Using it on multi-line images will lead to incorrect recognition results.