Aspose.OCR for Python via Java API docs
Loading...
Searching...
No Matches

AsposeOcr main class for recognition. More...

Public Member Functions

 __init__ (self)
 
typing.List[SkewOutputcalculate_skew (self, OcrInput input)
 Calculates the skew angles of an images.
 
bool compare_image_texts (self, str fullPath1, str fullPath2, RecognitionSettings settings=None, bool ignoreCase=True)
 Check if two images contain the same text.
 
str correct_spelling (self, str text, SpellCheckLanguage language)
 Corrects text (replaces misspelled words).
 
typing.List[DefectOutputdetect_defects (self, OcrInput input, aspose.models.DefectType defectType)
 Automatically find problematic areas of an image that can significantly impact the accuracy of OCR.
 
typing.List[RectangleOutputdetect_rectangles (self, OcrInput input, aspose.models.AreasType areasType, bool isDetectAreas)
 Detects text areas on images.
 
bool image_has_text (self, str fullPath, str text, RecognitionSettings settings=None, bool ignoreCase=True)
 Check if the image contains the provided text fragment.
 
float image_text_diff (self, str fullPath1, str fullPath2, RecognitionSettings settings=None, bool ignoreCase=True)
 Compare the texts on the two images and return a number representing how similar they are (0 to 1).
 
OcrOutput recognize (self, OcrInput input, RecognitionSettings settings=None)
 Recognizes image with the ability to specify RecognitionSettings.
 
OcrOutput recognize_car_plate (self, aspose.models.OcrInput input, aspose.recognitionsettings.CarPlateRecognitionSettings settings=None)
 Recognizes car plate with the ability to specify CarPlateRecognitionSettings.
 
typing.List[str] recognize_fast (self, OcrInput input)
 Recognizes text on good quality image.
 
OcrOutput recognize_id_card (self, aspose.models.OcrInput input, aspose.recognitionsettings.IDCardRecognitionSettings settings=None)
 Recognizes ID card with the ability to specify IDCardRecognitionSettings.
 
OcrOutput recognize_invoice (self, aspose.models.OcrInput input, aspose.recognitionsettings.InvoiceRecognitionSettings settings=None)
 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.
 
OcrOutput recognize_lines (self, OcrInput input, RecognitionSettings settings=None)
 Recognizes single line image with the ability to specify RecognitionSettings.
 
OcrOutput recognize_passport (self, aspose.models.OcrInput input, aspose.recognitionsettings.PassportRecognitionSettings settings=None)
 Recognizes passport with the ability to specify PassportRecognitionSettings.
 
OcrOutput recognize_receipt (self, aspose.models.OcrInput input, aspose.recognitionsettings.ReceiptRecognitionSettings settings=None)
 Recognize receipts with the ability to specify ReceiptRecognitionSettings.
 
 shutdown (self)
 Shut down the JVM machine.
 

Static Public Member Functions

 save_multipage_document (str fullFileName, Format saveFormat, List results)
 Allows to get multipage document from list of RecognitionResult objects.
 
 save_multipage_document_user_font (str fullFileName, Format saveFormat, List results, str embeddedFontPath)
 Allows to get multipage document from list of RecognitionResult objects.
 
 save_multipage_pdf_optimized (str fullFileName, List results, str embeddedFontPath, PdfOptimizationMode optimizePdf)
 Allows to get multipage document from list of RecognitionResult objects.
 

Detailed Description

AsposeOcr main class for recognition.

This sample shows how to recognize image.

api = AsposeOcr()
input = OcrInput(InputType.SINGLE_IMAGE)
input.add(os.path.join(self.dataDir, "SpanishOCR.bmp"))
result = api.recognize(input)

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self)

Member Function Documentation

◆ calculate_skew()

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

Calculates the skew angles of an images.

Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.

Parameters
input:py:any:~aspose.models.OcrInput. instance. The container with sources.
Returns
: List of skew angles in degrees - SkewOutput.

◆ compare_image_texts()

bool compare_image_texts (   self,
str  fullPath1,
str  fullPath2,
RecognitionSettings   settings = None,
bool   ignoreCase = True 
)

Check if two images contain the same text.

Parameters
fullPath1Path to the first image.
fullPath2Path to the second image.
settingsRecognition settings.
ignoreCaseTrue - means a case-insensitive search.
Returns
: True if images have the same text (90% similarity).

◆ correct_spelling()

str correct_spelling (   self,
str  text,
SpellCheckLanguage  language 
)

Corrects text (replaces misspelled words).

Parameters
textText for correction.
languageDictionary to use SpellCheckLanguage.
Returns
: Text with replaced words.

◆ detect_defects()

typing.List[DefectOutput] detect_defects (   self,
OcrInput  input,
aspose.models.DefectType  defectType 
)

Automatically find problematic areas of an image that can significantly impact the accuracy of OCR.

Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.

Parameters
input:py:any:~aspose.models.OcrInput. instance.
defectTypeThe types of defects to be recognized.
Returns
: List of DefectOutput with detected text areas or lines.

◆ detect_rectangles()

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

Detects text areas on images.

Supports GIF, PNG, JPEG, WBMP, TIFF, JFIF, TIFF, PDF, binary array, folder, array, zip archive, URL, base64.

Parameters
input:py:any:~aspose.models.OcrInput. instance.
areasTypeDeterminates wich rectangles to return - line, paragraphs or words.
isDetectAreasEnable automatic text areas detection.
Returns
: List of RectangleOutput with detected text areas or lines.

◆ image_has_text()

bool image_has_text (   self,
str  fullPath,
str  text,
RecognitionSettings   settings = None,
bool   ignoreCase = True 
)

Check if the image contains the provided text fragment.

Parameters
fullPathPath to the image.
textText fragment for searching on the image.
settingsRecognition settings.
ignoreCaseTrue - means a case-insensitive search.
Returns
: True if image contains text fragment. False - image doesn't contains text fragment.

◆ image_text_diff()

float image_text_diff (   self,
str  fullPath1,
str  fullPath2,
RecognitionSettings   settings = None,
bool   ignoreCase = True 
)

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

Parameters
fullPath1Path to the first image.
fullPath2Path to the second image.
settingsRecognition settings.
ignoreCaseTrue - means a case-insensitive search.
Returns
: 0 means that the texts are completely different; 1 means the texts are identical.

◆ recognize()

OcrOutput recognize (   self,
OcrInput  input,
RecognitionSettings   settings = None 
)

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.

Parameters
input:py:any:~aspose.models.OcrInput. instance.
settingsRecognitionSettings object.
Returns
: RecognitionResult list with images recognition results.

◆ recognize_car_plate()

OcrOutput recognize_car_plate (   self,
aspose.models.OcrInput  input,
aspose.recognitionsettings.CarPlateRecognitionSettings   settings = None 
)

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.

Parameters
input:py:any:~aspose.models.OcrInput. instance.
settingsCarPlateRecognitionSettings
Returns
: RecognitionResult list with images recognition results.

◆ recognize_fast()

typing.List[str] recognize_fast (   self,
OcrInput  input 
)

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.

Parameters
input:py:any:~aspose.models.OcrInput. instance.
Returns
: RecognitionResult list with images recognition results.

◆ recognize_id_card()

OcrOutput recognize_id_card (   self,
aspose.models.OcrInput  input,
aspose.recognitionsettings.IDCardRecognitionSettings   settings = None 
)

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.

Parameters
input:py:any:~aspose.models.OcrInput. instance.
settingsIDCardRecognitionSettings
Returns
: RecognitionResult list with images recognition results.

◆ recognize_invoice()

OcrOutput recognize_invoice (   self,
aspose.models.OcrInput  input,
aspose.recognitionsettings.InvoiceRecognitionSettings   settings = None 
)

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.

Parameters
input:py:any:~aspose.models.OcrInput. instance.
settingsInvoiceRecognitionSettings
Returns
: RecognitionResult list with images recognition results.

◆ recognize_lines()

OcrOutput recognize_lines (   self,
OcrInput  input,
RecognitionSettings   settings = None 
)

Recognizes single line image with the ability to specify RecognitionSettings.

Parameters
input:py:any:~aspose.models.OcrInput. instance.
settingsRecognitionSettings object.
Returns
: RecognitionResult list with images recognition results.

◆ recognize_passport()

OcrOutput recognize_passport (   self,
aspose.models.OcrInput  input,
aspose.recognitionsettings.PassportRecognitionSettings   settings = None 
)

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.

Parameters
input:py:any:~aspose.models.OcrInput. instance.
settingsPassportRecognitionSettings
Returns
: RecognitionResult list with images recognition results.

◆ recognize_receipt()

OcrOutput recognize_receipt (   self,
aspose.models.OcrInput  input,
aspose.recognitionsettings.ReceiptRecognitionSettings   settings = None 
)

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.

Parameters
input:py:any:~aspose.models.OcrInput. instance.
settingsReceiptRecognitionSettings
Returns
: RecognitionResult list with images recognition results.

◆ save_multipage_document()

save_multipage_document ( str  fullFileName,
Format  saveFormat,
List  results 
)
static

Allows to get multipage document from list of RecognitionResult objects.

Parameters
fullFileNameFilename with a path for saving recognition result in the selected format.
saveFormatDocument format (Docx, Txt, Pdf, Xlsx, Xml, Json).
results

◆ save_multipage_document_user_font()

save_multipage_document_user_font ( str  fullFileName,
Format  saveFormat,
List  results,
str  embeddedFontPath 
)
static

Allows to get multipage document from list of RecognitionResult objects.

Parameters
fullFileNameFilename with a path for saving recognition result in the selected format.
saveFormatDocument format (Docx, Txt, Pdf, Xlsx, Xml, Json).
resultsArray of RecognitionResult objects.
embeddedFontPathFull path to the user font.

◆ save_multipage_pdf_optimized()

save_multipage_pdf_optimized ( str  fullFileName,
List  results,
str  embeddedFontPath,
PdfOptimizationMode  optimizePdf 
)
static

Allows to get multipage document from list of RecognitionResult objects.

Parameters
fullFileNameFilename with a path for saving recognition result in the selected format.
resultsArray of RecognitionResult objects.
embeddedFontPathFull path to the user font.
optimizePdfReduce the PDF file size by lowering the quality of background images. By default, the original image quality is preserved.

◆ shutdown()

shutdown (   self)

Shut down the JVM machine.