Last active
July 27, 2021 16:14
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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