AsposeOcr

AsposeOcr class

Module: asposeocr

AsposeOcr main class for recognition. This sample shows how to recognize image.

Constructors

NameDescription
init

Methods

NameReturn TypeStaticDescription
calculate_skewtyping.List[SkewOutput]NoCalculates the skew angles of an images. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.
compare_image_textsboolNoCheck if two images contain the same text.
correct_spellingstrNoCorrects text (replaces misspelled words).
detect_rectanglestyping.List[RectangleOutput]NoDetects text areas on images. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.
image_has_textboolNoCheck if the image contains the provided text fragment.
image_text_difffloatNoCompare the texts on the two images and return a number representing how similar they are (0 to 1).
recognizetyping.List[RecognitionResult]NoRecognizes image with the ability to specify RecognitionSettings. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.
recognize_car_platetyping.List[RecognitionResult]NoRecognizes car plate with the ability to specify CarPlateRecognitionSettings. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.
recognize_fasttyping.List[RecognitionResult]NoRecognizes text on good quality image. Doesn’t use automatic image skew correction and text areas detection. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.
recognize_id_cardtyping.List[RecognitionResult]NoRecognizes ID card with the ability to specify IDCardRecognitionSettings. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.
recognize_invoicetyping.List[RecognitionResult]NoRecognize invoice with the ability to specify InvoiceRecognitionSettings Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.
recognize_linestyping.List[RecognitionResult]NoRecognizes single line image with the ability to specify RecognitionSettings.
recognize_passporttyping.List[RecognitionResult]NoRecognizes passport with the ability to specify PassportRecognitionSettings. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.
recognize_receipttyping.List[RecognitionResult]NoRecognize receipts with the ability to specify ReceiptRecognitionSettings. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.
recognize_street_phototyping.List[RecognitionResult]NoRecognizes text on street photos. Extract text from street photos, traffic camera images, ID cards, driver licenses, and other images with sparse text and noisy/colored backgrounds. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.
save_multipage_documentYesAllows to get multipage document from list of RecognitionResult objects.
shutdownNoShut down the JVM machine.

AsposeOcr Constructor

__init__(self)

AsposeOcr.calculate_skew

calculate_skew(self, OcrInput input) -> typing.List[SkewOutput]

Calculates the skew angles of an images. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.

ParameterTypeDescription
inputOcrInput:py:any:~aspose.models.OcrInput. instance. The container with sources.

Return Type: typing.List[SkewOutput] — List of skew angles in degrees - SkewOutput.

AsposeOcr.compare_image_texts

compare_image_texts(self, str fullPath1, str fullPath2, RecognitionSettings settings, bool ignoreCase) -> bool

Check if two images contain the same text.

ParameterTypeDescription
fullPath1strPath to the first image.
fullPath2strPath to the second image.
settingsRecognitionSettingsRecognition settings.
ignoreCaseboolTrue - means a case-insensitive search.

Return Type: bool — True if images have the same text (90% similarity).

AsposeOcr.correct_spelling

correct_spelling(self, str text, SpellCheckLanguage language) -> str

Corrects text (replaces misspelled words).

ParameterTypeDescription
textstrText for correction.
languageSpellCheckLanguageDictionary to use SpellCheckLanguage.

Return Type: str — Text with replaced words.

AsposeOcr.detect_rectangles

detect_rectangles(self, OcrInput input, aspose.models.AreasType areasType, bool isDetectAreas) -> typing.List[RectangleOutput]

Detects text areas on images. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.

ParameterTypeDescription
inputOcrInput:py:any:~aspose.models.OcrInput. instance.
areasTypeaspose.models.AreasTypeDeterminates wich rectangles to return - line, paragraphs or words.
isDetectAreasboolEnable automatic text areas detection.

Return Type: typing.List[RectangleOutput] — List of RectangleOutput with detected text areas or lines.

AsposeOcr.image_has_text

image_has_text(self, str fullPath, str text, RecognitionSettings settings, bool ignoreCase) -> bool

Check if the image contains the provided text fragment.

ParameterTypeDescription
fullPathstrPath to the image.
textstrText fragment for searching on the image.
settingsRecognitionSettingsRecognition settings.
ignoreCaseboolTrue - means a case-insensitive search.

Return Type: bool — True if image contains text fragment. False - image doesn’t contains text fragment.

AsposeOcr.image_text_diff

image_text_diff(self, str fullPath1, str fullPath2, RecognitionSettings settings, bool ignoreCase) -> float

Compare the texts on the two images and return a number representing how similar they are (0 to 1).

ParameterTypeDescription
fullPath1strPath to the first image.
fullPath2strPath to the second image.
settingsRecognitionSettingsRecognition settings.
ignoreCaseboolTrue - means a case-insensitive search.

Return Type: float — 0 means that the texts are completely different; 1 means the texts are identical.

AsposeOcr.recognize

recognize(self, OcrInput input, RecognitionSettings settings) -> typing.List[RecognitionResult]

Recognizes image with the ability to specify RecognitionSettings. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.

ParameterTypeDescription
inputOcrInput:py:any:~aspose.models.OcrInput. instance.
settingsRecognitionSettingsRecognitionSettings object.

Return Type: typing.List[RecognitionResult] — RecognitionResult list with images recognition results.

AsposeOcr.recognize_car_plate

recognize_car_plate(self, aspose.models.OcrInput input, aspose.recognitionsettings.CarPlateRecognitionSettings settings) -> typing.List[RecognitionResult]

Recognizes car plate with the ability to specify CarPlateRecognitionSettings. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.

ParameterTypeDescription
inputaspose.models.OcrInput:py:any:~aspose.models.OcrInput. instance.
settingsaspose.recognitionsettings.CarPlateRecognitionSettingsCarPlateRecognitionSettings

Return Type: typing.List[RecognitionResult] — RecognitionResult list with images recognition results.

AsposeOcr.recognize_fast

recognize_fast(self, OcrInput input) -> typing.List[RecognitionResult]

Recognizes text on good quality image. Doesn’t use automatic image skew correction and text areas detection. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.

ParameterTypeDescription
inputOcrInput:py:any:~aspose.models.OcrInput. instance.

Return Type: typing.List[RecognitionResult] — RecognitionResult list with images recognition results.

AsposeOcr.recognize_id_card

recognize_id_card(self, aspose.models.OcrInput input, aspose.recognitionsettings.IDCardRecognitionSettings settings) -> typing.List[RecognitionResult]

Recognizes ID card with the ability to specify IDCardRecognitionSettings. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.

ParameterTypeDescription
inputaspose.models.OcrInput:py:any:~aspose.models.OcrInput. instance.
settingsaspose.recognitionsettings.IDCardRecognitionSettingsIDCardRecognitionSettings

Return Type: typing.List[RecognitionResult] — RecognitionResult list with images recognition results.

AsposeOcr.recognize_invoice

recognize_invoice(self, aspose.models.OcrInput input, aspose.recognitionsettings.InvoiceRecognitionSettings settings) -> typing.List[RecognitionResult]

Recognize invoice with the ability to specify InvoiceRecognitionSettings Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.

ParameterTypeDescription
inputaspose.models.OcrInput:py:any:~aspose.models.OcrInput. instance.
settingsaspose.recognitionsettings.InvoiceRecognitionSettingsInvoiceRecognitionSettings

Return Type: typing.List[RecognitionResult] — RecognitionResult list with images recognition results.

AsposeOcr.recognize_lines

recognize_lines(self, OcrInput input, RecognitionSettings settings) -> typing.List[RecognitionResult]

Recognizes single line image with the ability to specify RecognitionSettings.

ParameterTypeDescription
inputOcrInput:py:any:~aspose.models.OcrInput. instance.
settingsRecognitionSettingsRecognitionSettings object.

Return Type: typing.List[RecognitionResult] — RecognitionResult list with images recognition results.

AsposeOcr.recognize_passport

recognize_passport(self, aspose.models.OcrInput input, aspose.recognitionsettings.PassportRecognitionSettings settings) -> typing.List[RecognitionResult]

Recognizes passport with the ability to specify PassportRecognitionSettings. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.

ParameterTypeDescription
inputaspose.models.OcrInput:py:any:~aspose.models.OcrInput. instance.
settingsaspose.recognitionsettings.PassportRecognitionSettingsPassportRecognitionSettings

Return Type: typing.List[RecognitionResult] — RecognitionResult list with images recognition results.

AsposeOcr.recognize_receipt

recognize_receipt(self, aspose.models.OcrInput input, aspose.recognitionsettings.ReceiptRecognitionSettings settings) -> typing.List[RecognitionResult]

Recognize receipts with the ability to specify ReceiptRecognitionSettings. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.

ParameterTypeDescription
inputaspose.models.OcrInput:py:any:~aspose.models.OcrInput. instance.
settingsaspose.recognitionsettings.ReceiptRecognitionSettingsReceiptRecognitionSettings

Return Type: typing.List[RecognitionResult] — RecognitionResult list with images recognition results.

AsposeOcr.recognize_street_photo

recognize_street_photo(self, OcrInput input) -> typing.List[RecognitionResult]

Recognizes text on street photos. Extract text from street photos, traffic camera images, ID cards, driver licenses, and other images with sparse text and noisy/colored backgrounds. Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.

ParameterTypeDescription
inputOcrInput:py:any:~aspose.models.OcrInput. instance.

Return Type: typing.List[RecognitionResult] — RecognitionResult list with images recognition results.

AsposeOcr.save_multipage_document (static)

save_multipage_document(str fullFileName, Format saveFormat, List results)

Allows to get multipage document from list of RecognitionResult objects.

ParameterTypeDescription
fullFileNamestrFilename with a path for saving recognition result in the selected format.
saveFormatFormatDocument format (Docx, Txt, Pdf, Xlsx, Xml, Json).
resultsList

AsposeOcr.shutdown

shutdown(self)

Shut down the JVM machine.