Optical Character Recognition (OCR) is the process of extracting text from images. You may have online and offline images from which you might need to extract text information. You can perform OCR on offline images, but you might be thinking that to perform OCR on online images, you would have to download them. Well, that is not required. In this article, you will learn how to perform OCR on images using their URL with C++.
- C++ API for Performing OCR on Images from URL
- Recognize Text by Performing OCR on an Image from URL using C++
- Recognize Text from Selected Image Areas by Defining Recognition Areas using C++
C++ API for Performing OCR on Images from URL
Aspose.OCR for C++ is an optical character recognition API that can reliably perform OCR operations on images and scanned documents. The API also enables you to perform OCR on images from URLs. You can either install the API through NuGet or download it directly from the Downloads section.
PM> Install-Package Aspose.OCR.Cpp
Recognize Text by Performing OCR on an Image from URL using C++
The following are the steps to perform OCR on images from URLs.
- Prepare the buffer for the result.
- Set the RecognitionSettings.
- Perform OCR on the image using the asposeocr_page_from_uri (const char * uri, wchar_t * buffer, size_t buffer_size, RecognitionSettings settings) method.
The following sample code shows how to perform OCR on an image from a URL using C++.
Recognize Text from Selected Image Areas by Defining Recognition Areas using C++
If you do not want to perform OCR on the whole image and want to get the result from specific image areas, you can define recognition areas to do just that. The following are the steps to set recognition areas for the OCR operation.
- Define the recognition areas in an array of rect structure.
- Prepare the buffer for the result.
- Set the value of the RecognitionSettings.rectangles struct member equal to the previously defined array of recognition areas.
- Set the value of the RecognitionSettings.rectangles_size struct member equal to the size of the recognition areas array.
- Perform OCR on the image using the asposeocr_page_from_uri (const char * uri, wchar_t * buffer, size_t buffer_size, RecognitionSettings settings) method.
The following sample code demonstrates how to use recognition areas to recognize text from specific areas of an image using C++.
Get a Free License
In order to try the API without evaluation limitations, you can request a free temporary license.
Conclusion
In this article, you have learned how to perform OCR on images from any URL address using C++. Furthermore, you have seen how to define recognition areas to perform OCR on only selected areas of the image. Aspose.OCR for C++ is a robust API that provides many additional features for performing OCR on images. You can explore the API in detail by visiting the official documentation. In case of any questions, please feel free to reach us on our free support forum.