Class AsposeOcr
Namespace: Aspose.OCR
Assembly: Aspose.OCR.dll (25.2.0)
Main API for Aspose OCR library
public class AsposeOcr
Inheritance
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Constructors
AsposeOcr()
public AsposeOcr()
Methods
CalculateSkew(OcrInput)
Calculates the skew angles of an images. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, folder, arrays, archives.
public List<skewoutput> CalculateSkew(OcrInput images)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
Returns
List<SkewOutput>
List of skew angles in degrees Aspose.OCR.SkewOutput.
CompareImageTexts(string, string, RecognitionSettings, bool)
Check if two images contain the same text.
public bool CompareImageTexts(string fullPath1, string fullPath2, RecognitionSettings settings = null, bool ignoreCase = true)
Parameters
fullPath1
string
Path to the first image.
fullPath2
string
Path to the second image.
settings
RecognitionSettings
Recognition settings.
ignoreCase
bool
True - means a case-insensitive search.
Returns
True if images have the same text (90% similarity).
CorrectSpelling(string, SpellCheckLanguage, string)
Corrects text (replaces misspelled words).
public string CorrectSpelling(string text, SpellCheckLanguage language = SpellCheckLanguage.Eng, string dictionaryPath = null)
Parameters
text
string
Text for correction.
language
SpellCheckLanguage
Dictionary to use.
dictionaryPath
string
Optionally. Full path to the user dictionary (frequency dictionary). Dictionary file format: Plain text file in UTF-8 encoding. Word and Word Frequency are separated by space or tab.Per default, the word is expected in the first column and the frequency in the second column. Every word-frequency-pair in a separate line.A line is defined as a sequence of characters followed by a line feed ("\n"), a carriage return ("\r"), or a carriage return immediately followed by a line feed("\r\n"). Every word is expected to be in lower case.
Returns
Text with replaced words.
DetectDefects(OcrInput, DefectType)
Automatically find problematic areas of an image that can significantly impact the accuracy of OCR. Supports PNG, JPEG, BMP, TIFF, JFIF, and GIF images provided as a file, stream, or pixel array. Supports bulk recognition.
public List<defectoutput> DetectDefects(OcrInput images, DefectType defectType)
Parameters
images
OcrInput
Source images Aspose.OCR.OcrInput
defectType
DefectType
The types of defects to be recognized Aspose.OCR.DefectType
Returns
List<DefectOutput>
Detected image defects or ab empty collection if no defect found Aspose.OCR.DefectOutput.
DetectLanguages(OcrInput)
Analyzes the text on the image to determine the languages it is written in. This allows to select the most suitable recognition language and helps in further text processing tasks such as spellchecking or translation.
public List<languagedetectionoutput> DetectLanguages(OcrInput images)
Parameters
images
OcrInput
Source images Aspose.OCR.OcrInput
Returns
List<LanguageDetectionOutput>
Returns a list of the most probable languages, ranked by likelihood Aspose.OCR.LanguageDetectionOutput.
DetectRectangles(OcrInput)
Detects text areas on images. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, folder, arrays, archives.
public List<rectangleoutput> DetectRectangles(OcrInput images)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
Returns
List<RectangleOutput>
List of Aspose.OCR.RectangleOutput with detected text areas or lines.
DetectRectangles(OcrInput, AreasType, bool)
Detects text areas on images. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, folder, arrays, archives.
public List<rectangleoutput> DetectRectangles(OcrInput images, AreasType areasType, bool detectAreas = true)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
areasType
AreasType
Determinates wich rectangles to return - line or paragraphs.
detectAreas
bool
Enable automatic text areas detection.
Returns
List<RectangleOutput>
List of Aspose.OCR.RectangleOutput with detected text areas or lines.
ImageHasText(string, string, RecognitionSettings, bool, bool)
Check if the image contains the provided text fragment.
public bool ImageHasText(string fullPath, string text, RecognitionSettings settings = null, bool ignoreCase = true, bool autoSkew = true)
Parameters
fullPath
string
Path to the image.
text
string
Text fragment for searching on the image.
settings
RecognitionSettings
Recognition settings.
ignoreCase
bool
True - means a case-insensitive search.
autoSkew
bool
Enables the automatic image skew correction.
Returns
True if image contains text fragment. False - image doesn’t contains text fragment.
Remarks
Recognizes image with the ability to specify Aspose.OCR.RecognitionSettings. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF.
ImageHasText(string, Regex, RecognitionSettings, bool)
Check if the image text matches the provided regular expression.
public bool ImageHasText(string fullPath, Regex regex, RecognitionSettings settings = null, bool autoSkew = true)
Parameters
fullPath
string
Path to the image.
regex
Regex
System.Text.RegularExpressions object with the provided pattern and options.
settings
RecognitionSettings
Recognition settings.
autoSkew
bool
Enables the automatic image skew correction.
Returns
True if image text matches the provided regular expression.
Remarks
Recognizes image with the ability to specify Aspose.OCR.RecognitionSettings. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF.
ImageTextDiff(string, string, RecognitionSettings, bool, bool)
Compare the texts on the two images and return a number representing how similar they are (0 to 1).
public float ImageTextDiff(string fullPath1, string fullPath2, RecognitionSettings settings = null, bool ignoreCase = true, bool autoSkew = true)
Parameters
fullPath1
string
Path to the first image.
fullPath2
string
Path to the second image.
settings
RecognitionSettings
Recognition settings.
ignoreCase
bool
True - means a case-insensitive search.
autoSkew
bool
Enables the automatic image skew correction.
Returns
0 means that the texts are completely different; 1 means the texts are identical.
Recognize(OcrInput)
Recognizes text on images / documents. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, directory, arrays, archives.
public OcrOutput Recognize(OcrInput images)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
Returns
List of Aspose.OCR.RecognitionResult objects with image recognition results.
Recognize(OcrInput, RecognitionSettings, CancellationToken)
Recognizes text on images / documents. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, directory, arrays, archives.
public OcrOutput Recognize(OcrInput images, RecognitionSettings settings, CancellationToken cancellationToken)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
settings
RecognitionSettings
Recognition settings Aspose.OCR.RecognitionSettings.
cancellationToken
CancellationToken
CancellationToken object.
Returns
List of Aspose.OCR.RecognitionResult objects with image recognition results.
Recognize(OcrInput, RecognitionSettings)
Recognizes text on images / documents. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, directory, arrays, archives.
public OcrOutput Recognize(OcrInput images, RecognitionSettings settings)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
settings
RecognitionSettings
Recognition settings Aspose.OCR.RecognitionSettings.
Returns
List of Aspose.OCR.RecognitionResult objects with image recognition results.
RecognizeCarPlate(OcrInput)
Recognizes text on car plate.
public OcrOutput RecognizeCarPlate(OcrInput images)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
Returns
List of Aspose.OCR.RecognitionResult objects with image recognition results.
Remarks
Recognizes car plates with the ability to specify Aspose.OCR.CarPlateRecognitionSettings. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, directory, arrays, archives.
RecognizeCarPlate(OcrInput, CarPlateRecognitionSettings)
Recognizes text on car plate.
public OcrOutput RecognizeCarPlate(OcrInput images, CarPlateRecognitionSettings settings)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
settings
CarPlateRecognitionSettings
Recognition settings Aspose.OCR.CarPlateRecognitionSettings.
Returns
List of Aspose.OCR.RecognitionResult objects with image recognition results.
Remarks
Recognizes car plates with the ability to specify Aspose.OCR.CarPlateRecognitionSettings. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, directory, arrays, archives.
RecognizeCharacters(OcrInput)
Detects symbols on images. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, folder, arrays, archives.
public List<characterrecognitionresult> RecognizeCharacters(OcrInput images)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
Returns
List<CharacterRecognitionResult>
List of Aspose.OCR.CharacterRecognitionResult with detected symbols data.
RecognizeCharacters(OcrInput, DetectAreasMode, Language)
Detects symbols on images. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, folder, arrays, archives.
public List<characterrecognitionresult> RecognizeCharacters(OcrInput images, DetectAreasMode detectAreasMode = DetectAreasMode.UNIVERSAL, Language language = Language.Latin)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
detectAreasMode
DetectAreasMode
Determines the type of neural network used for areas detection.
language
Language
Language used for OCR..
Returns
List<CharacterRecognitionResult>
List of Aspose.OCR.Character with detected symbols data.
RecognizeFast(OcrInput)
Recognizes text on images / documents. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, directory, arrays, archives.
public List<string> RecognizeFast(OcrInput images)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
Returns
List of string with image recognition results.
RecognizeHandwrittenText(OcrInput)
Recognizes handwritten text on images.
public OcrOutput RecognizeHandwrittenText(OcrInput images)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
Returns
List of Aspose.OCR.RecognitionResult objects with image recognition results.
Remarks
Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, directory, arrays, archives.
RecognizeIDCard(OcrInput)
Recognizes text on ID card.
public OcrOutput RecognizeIDCard(OcrInput images)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
Returns
List of Aspose.OCR.RecognitionResult objects with image recognition results.
Remarks
Recognizes ID cards with the ability to specify Aspose.OCR.IDCardRecognitionSettings. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, directory, arrays, archives.
RecognizeIDCard(OcrInput, IDCardRecognitionSettings)
Recognizes text on ID card.
public OcrOutput RecognizeIDCard(OcrInput images, IDCardRecognitionSettings settings)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
settings
IDCardRecognitionSettings
Recognition settings Aspose.OCR.IDCardRecognitionSettings.
Returns
List of Aspose.OCR.RecognitionResult objects with image recognition results.
Remarks
Recognizes ID cards with the ability to specify Aspose.OCR.IDCardRecognitionSettings. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, directory, arrays, archives.
RecognizeInvoice(OcrInput)
Recognizes text on invoices.
public OcrOutput RecognizeInvoice(OcrInput images)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
Returns
List of Aspose.OCR.RecognitionResult objects with image recognition results.
Remarks
Recognizes invoice with the ability to specify Aspose.OCR.InvoiceRecognitionSettings. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, directory, arrays, archives.
RecognizeInvoice(OcrInput, InvoiceRecognitionSettings)
Recognizes text on invoices.
public OcrOutput RecognizeInvoice(OcrInput images, InvoiceRecognitionSettings settings)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
settings
InvoiceRecognitionSettings
Recognition settings Aspose.OCR.InvoiceRecognitionSettings.
Returns
List of Aspose.OCR.RecognitionResult objects with image recognition results.
Remarks
Recognizes invoice with the ability to specify Aspose.OCR.InvoiceRecognitionSettings. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, directory, arrays, archives. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, directory, arrays, archives.
RecognizeLines(OcrInput)
Recognizes images that contain single line of text. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, folder, arrays, archives.
public OcrOutput RecognizeLines(OcrInput images)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
Returns
List of Aspose.OCR.RecognitionResult objects with image recognition results.
RecognizeLines(OcrInput, RecognitionSettings)
Recognizes images that contain single line of text. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, folder, arrays, archives.
public OcrOutput RecognizeLines(OcrInput images, RecognitionSettings settings)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
settings
RecognitionSettings
Recognition settings Aspose.OCR.RecognitionSettings.
Returns
List of Aspose.OCR.RecognitionResult objects with image recognition results.
RecognizePassport(OcrInput)
Recognizes text on passport.
public OcrOutput RecognizePassport(OcrInput images)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
Returns
List of Aspose.OCR.RecognitionResult objects with image recognition results.
Remarks
Recognizes passports with the ability to specify Aspose.OCR.PassportRecognitionSettings. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, directory, arrays, archives.
RecognizePassport(OcrInput, PassportRecognitionSettings)
Recognizes text on passport.
public OcrOutput RecognizePassport(OcrInput images, PassportRecognitionSettings settings)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
settings
PassportRecognitionSettings
Recognition settings Aspose.OCR.PassportRecognitionSettings.
Returns
List of Aspose.OCR.RecognitionResult objects with image recognition results.
Remarks
Recognizes passports with the ability to specify Aspose.OCR.PassportRecognitionSettings. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, directory, arrays, archives.
RecognizeReceipt(OcrInput)
Recognizes text on receipts.
public OcrOutput RecognizeReceipt(OcrInput images)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
Returns
List of Aspose.OCR.RecognitionResult objects with image recognition results.
Remarks
Recognizes invoice with the ability to specify Aspose.OCR.ReceiptRecognitionSettings. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, directory, arrays, archives.
RecognizeReceipt(OcrInput, ReceiptRecognitionSettings)
Recognizes text on receipts.
public OcrOutput RecognizeReceipt(OcrInput images, ReceiptRecognitionSettings settings)
Parameters
images
OcrInput
The container with sources.Aspose.OCR.OcrInput
settings
ReceiptRecognitionSettings
Recognition settings Aspose.OCR.ReceiptRecognitionSettings.
Returns
List of Aspose.OCR.RecognitionResult objects with image recognition results.
Remarks
Recognizes invoice with the ability to specify Aspose.OCR.ReceiptRecognitionSettings. Supports GIF, PNG, JPEG, BMP, TIFF, JFIF, stream, directory, arrays, archives.
SaveMultipageDocument(string, SaveFormat, List<recognitionresult>, string, PdfOptimizationMode)
Allows to get multipage document from list of RecognitionResult objects
public static void SaveMultipageDocument(string fullFileName, SaveFormat saveFormat, List<recognitionresult> results, string embeddedFontPath = null, PdfOptimizationMode optimizePdf = PdfOptimizationMode.MAXIMUM_QUALITY)
Parameters
fullFileName
string
Filename with a path for saving recognition result in the selected format.
saveFormat
SaveFormat
Document format (Docx, Txt, Pdf, Xlsx, Rtf, Json, Xml).
results
List<RecognitionResult>
List of Aspose.OCR.RecognitionResult objects.
embeddedFontPath
string
Optionally. Full path to the user font.
optimizePdf
PdfOptimizationMode
Reduce the PDF file size by lowering the quality of background images. By default, the original image quality is preserved.
SaveMultipageDocument(string, SaveFormat, List<recognitionresult>, bool, SpellCheckLanguage, string, string, PdfOptimizationMode)
Allows to get multipage document from list of RecognitionResult objects
public static void SaveMultipageDocument(string fullFileName, SaveFormat saveFormat, List<recognitionresult> results, bool applySpellingCorrection, SpellCheckLanguage language = SpellCheckLanguage.Eng, string dictionaryPath = null, string embeddedFontPath = null, PdfOptimizationMode optimizePdf = PdfOptimizationMode.MAXIMUM_QUALITY)
Parameters
fullFileName
string
Filename with a path for saving recognition result in the selected format.
saveFormat
SaveFormat
Document format (Docx, Txt, Pdf, Xlsx, Rtf, Json, Xml).
results
List<RecognitionResult>
List of Aspose.OCR.RecognitionResult objects.
applySpellingCorrection
bool
Set true to correct misspelled words in case you have such in your recognition result.
language
SpellCheckLanguage
Dictionary for spell check (optional).
dictionaryPath
string
Optionally. Full path to the user dictionary in .txt format. Format is [word - space - frequence(number)]. Example: the 23135851162\nthat 3400031103\n
embeddedFontPath
string
Optionally. Full path to the user font.
optimizePdf
PdfOptimizationMode
Reduce the PDF file size by lowering the quality of background images. By default, the original image quality is preserved.
SaveMultipageDocument(MemoryStream, SaveFormat, List<recognitionresult>, string, PdfOptimizationMode)
Allows to get multipage document from list of RecognitionResult objects
public static void SaveMultipageDocument(MemoryStream stream, SaveFormat saveFormat, List<recognitionresult> results, string embeddedFontPath = null, PdfOptimizationMode optimizePdf = PdfOptimizationMode.MAXIMUM_QUALITY)
Parameters
stream
MemoryStream
MemoryStream for saving recognition result in the selected format.
saveFormat
SaveFormat
Document format (Docx, Txt, Pdf, Xlsx, Rtf, Json, Xml).
results
List<RecognitionResult>
List of Aspose.OCR.RecognitionResult objects.
embeddedFontPath
string
Optionally. Full path to the user font.
optimizePdf
PdfOptimizationMode
Reduce the PDF file size by lowering the quality of background images. By default, the original image quality is preserved.
SaveMultipageDocument(MemoryStream, SaveFormat, List<recognitionresult>, bool, SpellCheckLanguage, string, string, PdfOptimizationMode)
Allows to get multipage document from list of RecognitionResult objects
public static void SaveMultipageDocument(MemoryStream stream, SaveFormat saveFormat, List<recognitionresult> results, bool applySpellingCorrection, SpellCheckLanguage language = SpellCheckLanguage.Eng, string dictionaryPath = null, string embeddedFontPath = null, PdfOptimizationMode optimizePdf = PdfOptimizationMode.MAXIMUM_QUALITY)
Parameters
stream
MemoryStream
MemoryStream for saving recognition result in the selected format.
saveFormat
SaveFormat
Document format (Docx, Txt, Pdf, Xlsx, Rtf, Json, Xml).
results
List<RecognitionResult>
List of Aspose.OCR.RecognitionResult objects.
applySpellingCorrection
bool
Set true to correct misspelled words in case you have such in your recognition result.
language
SpellCheckLanguage
Dictionary for spell check (optional).
dictionaryPath
string
Optionally. Full path to the user dictionary in .txt format. Format is [word - space - frequence(number)]. Example: the 23135851162\nthat 3400031103\n
embeddedFontPath
string
Optionally. Full path to the user font.
optimizePdf
PdfOptimizationMode
Reduce the PDF file size by lowering the quality of background images. By default, the original image quality is preserved.
OcrProgress
An event to track the progress of multi-page image recognition.
public event OcrRecognizeEventHandler OcrProgress
Event Type
OcrRecognizeEventHandler </recognitionresult></recognitionresult></recognitionresult></recognitionresult>