Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert Image to Text using C++
std::string image_path = "sample_line.jpg";
// Prepare buffer for result (in symbols, len_byte = len * sizeof(wchar_t))
const size_t len = 4096;
wchar_t buffer[len] = { 0 };
int x = 138, y = 352, w = 2033, h = 537;
// Perform OCR or selected area
size_t size = aspose::ocr::page_rect(image_path.c_str(), buffer, len, x, y, w, h);
//Print result
std::wcout << buffer << L"\n";
std::string image_path = "sample_line.jpg";
// Prepare buffer for result (in symbols, len_byte = len * sizeof(wchar_t))
const size_t len = 4096;
wchar_t buffer[len] = { 0 };
// Perform OCR
size_t size = aspose::ocr::line(image_path.c_str(), buffer, len);
//Print result
std::wcout << buffer << L"\n";
std::string image_path = "sample.png";
// Prepare buffer for result (in symbols, len_byte = len * sizeof(wchar_t))
const size_t len = 4096;
wchar_t buffer[len] = { 0 };
// Perform OCR
size_t size = aspose::ocr::page(image_path.c_str(), buffer, len);
//Print result
std::wcout << buffer << L"\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.