Conversion is need for business applications for recognizing OCR for making the text editable, reading codes from vouchers and self-service stores etc. Converting different images BMP, GIF, JPG, PNG to Text of various languages is simple by integrating the C++ library. Programmers can easily use the code for extracting single line text, whole page text, text within a particular area and more for any OCR application having the best recognition results and can handle any text fonts, page layouts and styles.
To extract text from images via C++ OCR API, Process depends on scenario for using the relevant function to perform OCR on page, or image containing a single line. API provides page (const char * image_path, wchar_t * buffer, size_t buffer_size), pages_multi (const char *path_to_recognize, wchar_t *buffer, size_t buffer_size, RecognitionSettings settings), line (const char *image_path, wchar_t *buffer, size_t buffer_size) and more. Here is list of all OCR functions that developers can perform easily. Below are the code examples for performing ocr on a page and line.
std::string png_image_path = "sample.png"; | |
// Prepare buffer for result (in symbols, len_byte = length * sizeof(wchar_t)) | |
const size_t leng = 4096; | |
wchar_t bffr[leng] = { 0 }; | |
// Perform OCR on Page | |
size_t size = aspose::ocr::page(png_image_path.c_str(), bffr, leng); | |
//Print result | |
std::wcout << bffr << L"\n"; |
std::string path = "sourceImage.jpg"; | |
// Prepare buffer for result (in symbols, len_byte = length * sizeof(wchar_t)) | |
const size_t leng = 4096; | |
wchar_t bfr[leng] = { 0 }; | |
int x = 138, y = 352, w = 2033, h = 537; | |
// Perform OCR of page selected area | |
size_t size = aspose::ocr::page_rect(path.c_str(), bfr, leng, x, y, w, h); | |
//Print result | |
std::wcout << bfr << L"\n"; |
std::string path = "sample_image.jpg"; | |
// Prepare buffer for result (in symbols, len_byte = len * sizeof(wchar_t)) | |
const size_t leng = 4096; | |
wchar_t bffr[leng] = { 0 }; | |
// Perform OCR to extract line text from image | |
size_t size = aspose::ocr::line(image_path.c_str(), bffr, leng); | |
//Print result | |
std::wcout << bffr << L"\n"; |
</div>
</div>
</div>
</div>