Convert image to text with Python OCR API via Java
Recognize Text in Images with Python
More showcases ># Initialize OCR engine
recognitionEngine = AsposeOcr()
# Add image to batch
input = OcrInput(InputType.SINGLE_IMAGE)
input.add("sample.png")
# Extract text from image
result = recognitionEngine.recognize(input)
# Display the recognition result
print(result[0].recognition_text)
> pip install aspose-ocr-python-java or
download
Why Aspose.OCR for Python via Java?
Aspose.OCR for Python via Java seamlessly integrates powerful optical character recognition (OCR) capabilities into your cross-platform Python notebooks and applications. With our intuitive and high-speed API, you can effortlessly extract text from scans, screenshots, web links, or smartphone photos, delivering results that are ready for consolidation, analysis, or storage. Recognize scanned images, smartphone photos, screenshots, and scanned PDFs, saving results in popular document formats. Advanced pre-processing filters handle rotated, skewed, and noisy images. Optimize performance by offloading tasks to the GPU.
Swift and Accurate OCR
Achieve high-speed and accurate OCR results with our advanced Python via Java technology.
Multilingual Support
Recognize text in 130+ languages, including Latin, Cyrillic, Arabic, Persian, Indic, and Chinese scripts, ensuring versatility for your Python applications via Java.
Flexible Image Support
Process images from scanners, cameras, and smartphones seamlessly with Python via Java.
Precision in Chinese Character Recognition
Recognize over 6,000 Chinese characters with precision in your Python projects via Java.
Preserve Font Styles and Formatting
Maintain font styles and formatting for accurate representation of recognized text in your Python applications via Java.
Live code sample
Initiate text recognition from images in just three lines of code. Experience the simplicity!
* By uploading your files or using the service you agree with our Terms of use and Privacy Policy.
Convert image to text
More examples ># Initialize OCR engine
recognitionEngine = AsposeOcr()
# Add image to batch
input = OcrInput(InputType.SINGLE_IMAGE)
input.add("sample.png")
# Extract text from image
result = recognitionEngine.recognize(input)
# Display the recognition result
print(result[0].recognition_text)
Choose your preference
Choose the right library for your needs. Explore available APIs and their capabilities to select the most efficient solution.
Versatility
Python via .NET
Uniformity
Python via Java
Performance
Python via C++
Java Backend Compatibility
Designed as a Python module, our library ensures compatibility across major operating systems supporting Java - including Microsoft Windows, Linux, and macOS, or the cloud platforms. This enables you to develop applications on one platform and seamlessly run them on another, eliminating the need for any code modifications.
Supported file formats
Aspose.OCR for Python via Java can work with virtually any file you can get from a scanner or camera. Recognition results are returned in the most popular file and data exchange formats that can be saved, imported to a database, or analyzed in real time.
Images
- JPEG
- PNG
- TIFF
- GIF
- Bitmap
Batch OCR
- Multi-page PDF
- ZIP
- Folder
Recognition results
- Text
- Microsoft Word
- Microsoft Excel
- HTML
- RTF
- ePub
- JSON
- XML
Effortless Installation for Python via Java
Aspose.OCR for Python via Java is delivered as a Python package or as a downloadable file with minimal dependencies. Easily install it into your project, and you’re ready to recognize texts in multiple supported languages and save recognition results in various formats.
Request a trial license to kickstart the development of a fully functional OCR application without limitations.
Powerful OCR for Python Applications
Our library integrates easily, enabling Python applications to run seamlessly on any platform – desktop Windows, Windows Server, macOS, Linux, and the cloud.
130+ Recognition Languages
Our Python and Java OCR API recognizes a plethora of languages and popular writing scripts, including mixed languages:
Leave language detection to the library or define the language yourself for enhanced recognition performance and reliability.
- Extended Latin alphabet: English, Spanish, French, Indonesian, Portuguese, German, Vietnamese, Turkish, Italian, Polish, and 80+ more;
- Cyrillic alphabet: Russian, Ukrainian, Kazakh, Serbian, Belarusan, Bulgarian;
- Arabic, Persian, Urdu;
- Chinese and Devanagari script, including Hindi, Marathi, Bhojpuri, and others.
Enhanced Image Processing Filters
The precision of optical character recognition relies heavily on the quality of the original image. Aspose.OCR for Python via Java offers a wide array of both automated and manual image processing filters to optimize an image before submission to the OCR engine:
- Automatically straighten slightly tilted images.
- Manually correct the rotation of severely skewed images.
- Automatically remove dirt, spots, scratches, glare, unwanted gradients, and other types of noise.
- Automatically adjust the image contrast.
- Automatically upscale or manually resize the image.
- Convert images to black and white or grayscale.
- Invert image colors, making light areas appear dark and dark areas appear light.
- Increase the thickness of characters in an image.
- Blur noisy images while preserving letter edges.
- Straighten page skew and correct camera lens distortion in page photos.
Specilized APIs for various document types
Aspose.OCR for Python via Java offers specially trained neural networks to extract text from certain types of images with maximum accuracy:
- Scanned or photographed ID cards and passports.
- Vehicle license plates.
- Invoices.
- Receipts.
Built-in spell checker
Although Aspose.OCR for Python via Java provides high recognition accuracy, printing defects, dirt, or non-standard fonts may cause certain characters or words to be recognized incorrectly. To further improve recognition results, you can turn on spell checker, which finds and automatically corrects spelling errors based on the selected recognition language.
If the recognized text contains specialized terminology, abbreviations, and other words which are not present in common spelling dictionaries, you can provide your own word lists.
Efficient Batch Recognition
Our Python OCR API empowers you to streamline image recognition. Utilize versatile batch-processing methods for efficient processing of multiple images in a single call:
- Recognize multi-page PDF, TIFF files.
- Process all files within a folder.
- Handle recognition for all files in an archive.
- Recognize images from a specified list.
Learning via Python Examples
Explore a variety of Python examples designed to help you swiftly grasp the functions and capabilities of our OCR solution. Quickly gain insight into creating customized solutions that meet your specific business requirements.
Features and Capabilities
Aspose.OCR for Python via Java Explore the advanced features of Aspose.OCR for Python
Photo OCR
Extract text from smartphone photos with scan-level accuracy.
Searchable PDF
Convert any scan into a fully searchable and indexable document.
URL recognition
Recognize an image from URL without downloading it locally.
Bulk recognition
Read all images from multi-page documents, folders and archives.
Any font and style
Identify and recognize text in all popular typefaces and styles.
Fine-tune recognition
Adjust every OCR parameter for best recognition results.
Spell checker
Improve results by automatically correcting misspelled words.
Find text in images
Search for text or regular expression within a set of images.
Compare image texts
Compare texts on two images, regardless of the case and layout.
Python Code Samples
Discover code samples to seamlessly integrate Aspose.OCR for Python via Java into your applications.
Effortless Installation
As a Python package or a downloadable file with minimal dependencies, Aspose.OCR for Python via Java ensures easy distribution. Integrate it into your project directly from Python, and you’re prepared to leverage complete OCR capabilities, saving recognition results in various formats.
Post-installation, promptly commence using Aspose.OCR for Python via Java, albeit with certain limitations. A temporary license removes all trial version restrictions for 30 days. Utilize this period to initiate the development of a fully functional OCR application, allowing you to make an informed decision on purchasing Aspose.OCR for Python via Java later.
Load license
lic = License()
lic.set_license(self.licPath)
Image Recognition
The primary challenge in OCR applications is the scarcity of scanners for end users. Our API, seamlessly integrated with Python via Java, features robust built-in image pre-processing filters handling rotated, skewed, and noisy images. Combined with support for all image formats, it allows reliable recognition, even from smartphone photos. Most pre-processing and image correction are automated, requiring your intervention only in challenging cases.
Apply automatic image corrections - Python
api = AsposeOcr()
# set preprocessing options
filters = PreprocessingFilter()
filters.add(PreprocessingFilter.auto_skew())
# Create OcrInput and add images
input = OcrInput(InputType.SINGLE_IMAGE, filters)
input.add("sample.png")
# set recognition options
settings = RecognitionSettings()
settings.set_detect_areas_mode(DetectAreasMode.TABLE)
settings.set_threads_count(1)
settings.set_language(Language.ENG)
# recognize
result = api.recognize(input, settings)
# print result
print(res[0].recognition_text)
Python Universal Converter
Our API adeptly reads any image from scanners, cameras, or smartphones: PDF documents, JPEG, PNG, TIFF, GIF, BMP files. Full support for multi-page PDF documents, TIFF, and DjVu images ensures versatility. You can also provide an image from the web via a URL.
Recognition results are returned in popular document and data exchange formats: plain text, PDF, Microsoft Word, Microsoft Excel, JSON, and XML.
Recognize PDF and Save Results to various output formats - Python
api = AsposeOcr()
# Create OcrInput and add images
input = OcrInput(aspose.models.InputType.PDF)
file = os.path.join(self.dataDir, "pdfs/multi_page_1.pdf")
input.add(file, 0, 3)
set = RecognitionSettings()
set.set_detect_areas_mode(DetectAreasMode.NONE)
result = api.recognize(input, set)
api.save_multipage_document("test.xml", Format.XML, result)
api.save_multipage_document("test.json", Format.JSON, result)
api.save_multipage_document("test.pdf", Format.PDF, result)
api.save_multipage_document("test.xlsx", Format.XLSX, result)
api.save_multipage_document("test.docx", Format.DOCX, result)
api.save_multipage_document("test.txt", Format.TEXT, result)
api.save_multipage_document("test.html", Format.HTML, result)
api.save_multipage_document("test.epub", Format.EPUB, result)
api.save_multipage_document("test.rtf", Format.RTF, result)
Optimizing Resource Usage
OCR offers a special recognition algorithm for extracting content from images with sparse text and noisy/colored backgrounds. This method significantly improves OCR accuracy in the following business cases:
- Read text from street photos.
- Segment and identify road signs and signboards within street images.
- Locate price tags and interpret the extracted text as prices.
- Find and aggregate regions of interest on food labels, such as nutritional information or ingredient lists.
- Identify and analyze car license plates.
- Extract text from menus and catalogs.
Open area OCR - Python
api = AsposeOcr()
# Create OcrInput and add images
input = OcrInput(InputType.SINGLE_IMAGE)
input.add("border.jpg")
result = api.recognize(input, RecognitionSettings())
result_street = api.recognize_street_photo(input)
print(result[0].recognition_text)
Extracting text from street photos
OCR for Python offers a special recognition algorithm that extracts text from vehicle license plates, including dark and blurry photos. The resulting text can then be automatically saved to the database or automatically verified.
Recognize car number - Python
api = AsposeOcr()
# Create OcrInput and add images
input = OcrInput(InputType.SINGLE_IMAGE)
input.add(os.path.join(self.dataDir, "CarNumbers.jfif"))
# recognize
result = api.recognize_car_plate(input, CarPlateRecognitionSettings())
# print result
print(result[0].recognition_text)