Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/4c269d51138145682aec13d13f680a66 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/4c269d51138145682aec13d13f680a66 to your computer and use it in GitHub Desktop.
Recognize Text by Performing OCR on Image from URL using C++ | https://blog.aspose.com/2021/07/08/recognize-text-by-performing-ocr-on-image-from-url-using-cpp/
Read the complete article about recognizing text by performing OCR on an image from URL using C++ by visiting the following link.
https://blog.aspose.com/2021/07/08/recognize-text-by-performing-ocr-on-image-from-url-using-cpp/
#include <fcntl.h>
#ifdef _WIN32
#include <corecrt_io.h>
#endif
int main()
{
#ifdef _WIN32
_setmode(_fileno(stdout), _O_U16TEXT);
#else
setlocale(LC_CTYPE, "");
#endif
// Source file url
const char* uri = "https://www.castlegateit.co.uk/wp-content/uploads/2016/09/justified_text.png";
// Define the Recognition areas
rect rectangles[2] = { {90, 180, 770, 333} , { 923, 613, 780, 96 } };
// Prepare buffer for result (in symbols, len_byte = len * sizeof(wchar_t))
const size_t len = 4096;
wchar_t buffer[len] = { 0 };
// Set the recognition settings
RecognitionSettings settings;
settings.format = export_format::text;
// Set the recognition areas
settings.rectangles = rectangles;
// Specify the size of the recognition areas array
settings.rectangles_size = 2;
// Perform the OCR operation on the image.
size_t res = asposeocr_page_from_uri(uri, buffer, len, settings);
std::wcout << buffer << L"\n";
}
#include <fcntl.h>
#ifdef _WIN32
#include <corecrt_io.h>
#endif
int main()
{
#ifdef _WIN32
_setmode(_fileno(stdout), _O_U16TEXT);
#else
setlocale(LC_CTYPE, "");
#endif
// Source file url
const char* uri = "https://www.castlegateit.co.uk/wp-content/uploads/2016/09/justified_text.png";
// Prepare buffer for result (in symbols, len_byte = len * sizeof(wchar_t))
const size_t len = 4096;
wchar_t buffer[len] = { 0 };
// Set the recognition settings
RecognitionSettings settings;
settings.format = export_format::text;
// Perform the OCR operation on the image.
size_t res = asposeocr_page_from_uri(uri, buffer, len, settings);
std::wcout << buffer << L"\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment