Image to text with C++ Library
Turn images into text
More showcases >AsposeOCRInput source;
source.url = file_path_str.c_str();
vector<AsposeOCRInput> content = {source};
// Extract text from the image
AsposeOCRRecognitionResult result
= asposeocr_recognize(content.data(), content.size());
// Output the recognized text
size_t size = 0;
wchar_t* result = asposeocr_serialize_result(result, size);
> Install-Package Aspose.Ocr.Cpp
Why Aspose.OCR for C++?
Create and recognize machine-readable forms of any layout and complexity in on-premise applications, web services, or in the cloud. Our solution is suitable for projects of any size - from simple surveys and quizzes to final exams and elections. Click the items below to learn more about our features and benefits.
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.
Live code sample
Experience simplicity: Convert an image to text in just three lines of C++ code!
* By uploading your files or using the service you agree with our Terms of use and Privacy Policy.
Convert image to text
Discover More Examples > string file = "source.png";
AsposeOCRInput source;
source.url = file.c_str();
vector<AsposeOCRInput> content = {source};
RecognitionSettings settings;
settings.language_alphabet = language::eng;
size_t size = 0;
wchar_t* buffer = asposeocr_serialize_result(result, size);
wcout << wstring(buffer) << endl;
asposeocr_free_result(result);
C++ Power Everywhere
Aspose.OCR for C++ seamlessly operates on any platform.
Supported file formats
Aspose.OCR for C++ 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
- BMP
Batch OCR
- Multi-page PDF
- ZIP
- Folder
Recognition results
- Text
- Microsoft Word
- Microsoft Excel
- RTF
- JSON
- XML
Installation
Aspose.OCR library for C++ is distributed as a NuGet 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.
C++ Power Across the Board
Our library fully supports C++11 and later, enabling your applications to run seamlessly on any platform – desktop Windows, Windows Server, macOS, Linux, and the cloud.
130+ Recognition Languages
Our C++ 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.
Features and Capabilities that Empower
Aspose.OCR for C++ Discover the advanced features and capabilities of Aspose.OCR for C++.
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.
Limit recognition scope
Limit the set of characters the OCR engine will look for.
Detect image defects
Automatically find potentially problematic areas of image.
Recognize areas
Find and read only specific areas of an image, not all text.
C++ Code Samples
Delve into code samples to seamlessly integrate Aspose.OCR for C++ into your applications.
C++ Installation Mastery
Post-installation, you can promptly commence using Aspose.OCR for C++, albeit with certain limitations. A temporary license lifts 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 C++ at a later stage.
OCR for C++ Photos
Overcome the challenge of OCR applications lacking widespread scanners. Our API boasts powerful built-in image pre-processing filters that adeptly handle rotated, skewed, and noisy images. Combined with support for all image formats, it ensures reliable recognition even from smartphone photos. Most pre-processing and image correction are automated, requiring your intervention only in challenging cases. Also you can predefine image regions to work with.
Set custom angle for skew correction and define recognition regions - C++
string file = "photo.png";
AsposeOCRInput source;
source.url = file.c_str();
std::vector<AsposeOCRInput> content = { source };
// Fine-tune recognition
RecognitionSettings settings;
settings.detect_areas_mode = detect_areas_mode_enum::PHOTO;
// Extract text from the photo
auto result = asposeocr_recognize(content.data(), content.size(), settings);
// Output the recognized text
wchar_t* buffer = asposeocr_serialize_result(result, buffer_size, export_format::text);
std::wcout << std::wstring(buffer) << std::endl;
// Release the resources
asposeocr_free_result(result);
Detecting image defects
Image defects can significantly impact the accuracy of OCR. They can be caused by the quality of the image acquisition process, environmental conditions, and the hardware used to capture the image. To improve recognition accuracy, it is essential to preprocess and enhance images to mitigate these defects whenever possible.Aspose.OCR for C++ can automatically find potentially problematic areas of image during recognition. You can highlight problem areas when previewing an image and even OCR them using alternative recognition settings to get a better result.
Recognize text on blurry, distorted and low contrast images - C++
// Provide the image
string file = "source.png";
AsposeOCRInput source;
source.url = file.c_str();
vector<AsposeOCRInput> content = {source};
// Activate detection of low-contrast areas
RecognitionSettings settings;
settings.defect_type = defect_type::ASPOSE_OCR_DETECT_DARK_IMAGES;
// Find and show low-contrast areas
AsposeOCRRecognitionResult result = asposeocr_recognize(content.data(), content.size(), settings);
for (size_t p_number = 0; p_number < result.pages_amount; ++p_number)
{
cout << "Page " << p_number << ";\n";
const auto& page = result.recognized_pages[p_number];
for (size_t defect_number = 0; defect_number < page.defects_count; ++defect_number)
{
const auto& defect_area = page.defect_areas[defect_number];
cout << "Low-contrast area " << defect_number << ":" << defect_area.area << std::endl;
}
}
// Release the resources
asposeocr_free_result(result);
Batch Processing
OCR API frees you from recognizing every image one-by-one by offering various batch-processing methods that allow you to recognize multiple images in one call:
- Recognition of multi-page PDF and TIFF files.
- Recognition of all files in a folder.
- Recognition of all files in an archive.
Recognize ZIP archive - C++
// Provide a ZIP archive
string file = "pages.zip";
AsposeOCRInput source;
source.url = file.c_str();
std::vector<AsposeOCRInput> content = { source };
// Fine-tune recognition
RecognitionSettings settings;
settings.detect_areas_mode = detect_areas_mode_enum::COMBINE;
// Extract texts
auto result = asposeocr_recognize(content.data(), content.size(), settings);