翻譯|使用教程|編輯:李顯亮|2021-06-18 10:03:54.803|閱讀 330 次
概述:使用 OCR,可以將圖像轉(zhuǎn)換為可搜索和可編輯的 Word 文檔。為此,本文將教您如何使用 C++ 將圖像轉(zhuǎn)換為 Word 文檔。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
圖像和掃描的文檔可能包含您可能需要進一步處理的文本信息。可能已經(jīng)使用智能手機拍攝了文本文檔的圖片,并將其轉(zhuǎn)換為可編輯的文檔。為此,對圖像執(zhí)行 OCR 可以證明是有幫助的。使用 OCR,可以將圖像轉(zhuǎn)換為可搜索和可編輯的 Word 文檔。為此,本文將教您 如何使用 C++ 將圖像轉(zhuǎn)換為 Word 文檔。
Aspose.OCR 是一種光學(xué)字符識別 API,可以從圖像中提取文本。該 API 還使您能夠?qū)D像轉(zhuǎn)換為 Word 文檔和文本文件。如果你還沒有用過Aspose.OCR可以點擊這里下載最新版測試。
通常您可能需要搜索或編輯圖像中的文本,但您無法這樣做。通過對此類圖像執(zhí)行 OCR 并將其轉(zhuǎn)換為 Word 文檔,您可以根據(jù)需要搜索和編輯文本。為此,請按照以下步驟操作。
以下示例代碼顯示了如何使用 C++ 將圖像轉(zhuǎn)換為 Word 文檔:
// Source file path std::string image_path = "SourceDirectory\\sample.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.save_format = file_format::docx; // Perform the OCR operation and save the output file. asposeocr_page_save(image_path.c_str(), "OutputDirectory\\ImageToDocx.Docx", settings);
圖像和掃描的文檔有時會傾斜。使用 Aspose.OCR for C++ API,您可以對傾斜的圖像執(zhí)行 OCR。以下是將傾斜圖像轉(zhuǎn)換為 Word 文檔的步驟:
以下示例代碼顯示了如何使用 C++ 將傾斜圖像轉(zhuǎn)換為 Word 文檔:
// Source file path std::string image_path = "SourceDirectory\\skewSample.png"; // Prepare buffer for result (in symbols, len_byte = len * sizeof(wchar_t)) const size_t len = 4096; wchar_t buffer[len] = { 0 }; // Calculate skew angle std::double_t angle = asposeocr_get_skew(image_path.c_str()); // Set the recognition settings RecognitionSettings settings; settings.save_format = file_format::docx; settings.skew = angle; // Perform the OCR operation and save the output file. asposeocr_page_save(image_path.c_str(), "OutputDirectory\\SkewedImageToDocx.docx", settings);
如果你想試用Aspose的全部完整功能,可聯(lián)系在線客服獲取30天臨時授權(quán)體驗。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn