使用 C++ 庫將圖像轉為文字
將圖像轉換為文字
更多展示 >AsposeOCRInput source;
source.url = file_path_str.c_str();
vector<AsposeOCRInput> content = {source};
// Extract text from the image
AsposeOCRRecognitionResult result
= asposeocr_recognize(content.data(), content.size());
// Output the recognized text
size_t size = 0;
wchar_t* result = asposeocr_serialize_result(result, size);
> Install-Package Aspose.Ocr.Cpp
為什麼適用於 C++ 的 Aspose.OCR?
在本機應用程式、Web 服務或雲端中建立和識別任何佈局和複雜性的機器可讀形式。我們的解決方案適用於任何規模的項目 - 從簡單的調查和測驗到期末考試和選舉。點擊下面的項目以了解有關我們的功能和優勢的更多資訊。
照片識別
以掃描級精度從智慧型手機照片中提取文字。
可搜尋的 PDF
將任何掃描結果轉換為完全可搜尋和可索引的文件。
網址識別
從 URL 識別圖像,無需下載到本機。
大量識別
讀取多頁文件、資料夾和檔案中的所有影像。
任何字體和样式
識別並識別所有流行字體和样式的文字。
即時程式碼範例
體驗簡單性:只需三行 C++ 程式碼即可將圖像轉換為文字!
將圖像轉換為文字
發現更多範例 > string file = "source.png";
AsposeOCRInput source;
source.url = file.c_str();
vector<AsposeOCRInput> content = {source};
RecognitionSettings settings;
settings.language_alphabet = language::eng;
size_t size = 0;
wchar_t* buffer = asposeocr_serialize_result(result, size);
wcout << wstring(buffer) << endl;
asposeocr_free_result(result);
C++ 力量無所不在
Aspose.OCR for C++ 可在任何平台上無縫運作。
支援的文件格式
Aspose.OCR for C++ 可以處理任何 文件 您可以透過掃描器或相機取得。識別結果可以儲存、匯入資料庫或即時分析。
圖片
- JPEG
- PNG
- TIFF
- BMP
批量OCR
- Multi-page PDF
- ZIP
- Folder
識別結果
- Text
- Microsoft Word
- Microsoft Excel
- RTF
- JSON
- XML
C++ 全面強大
我們的程式庫完全支援 C++11 及更高版本,讓您的應用程式能夠在任何平台上無縫運行 - 桌面 Windows、Windows Server、macOS、Linux 和雲端。
130+ 識別語言
我們的 C++ OCR API 可識別多種語言和流行的書寫腳本,包括混合語言:
將語言偵測留給程式庫或您自己定義語言,以增強識別效能和可靠性。
- 擴展拉丁字母:英語、西班牙語、法語、印尼語、葡萄牙語、德語、越南語、土耳其語、義大利語、波蘭語等 80 多種;
- 西里爾文字母:俄語、烏克蘭語、哈薩克語、塞爾維亞語、白俄羅斯語、保加利亞語;
- 阿拉伯語、波斯語、烏爾都語;
- 中文和梵文文字,包括印地語、馬拉地語、博傑普爾語等。
賦能的特性與功能
Aspose.OCR for C++ 探索 Aspose.OCR for C++ 的高階特性和功能。
照片識別
以掃描級精度從智慧型手機照片中提取文字。
可搜尋的 PDF
將任何掃描結果轉換為完全可搜尋和可索引的文件。
網址識別
從 URL 識別圖像,無需下載到本機。
大量識別
讀取多頁文件、資料夾和檔案中的所有影像。
任何字體和样式
識別並識別所有流行字體和样式的文字。
微調識別
調整每個 OCR 參數以獲得最佳識別結果。
拼字檢查器
透過自動更正拼字錯誤的單字來提高結果。
尋找圖像中的文本
在一組圖像中搜尋文字或正規表示式。
比較圖像文本
比較兩個圖像上的文本,無論大小寫和佈局如何。
限制識別範圍
限制 OCR 引擎將尋找的字元集。
檢測影像缺陷
自動尋找影像中可能有問題的區域。
識別區域
僅查找和讀取圖像的特定區域,而不是所有文字。
C++ 程式碼範例
深入研究程式碼範例,將 Aspose.OCR for C++ 無縫整合到您的應用程式中。
C++安裝掌握
C++ 照片 OCR
克服 OCR 應用程式缺乏廣泛掃描器的挑戰。我們的 API 擁有強大的內建影像預處理過濾器,可熟練處理旋轉、傾斜和雜訊影像。結合對所有圖像格式的支持,即使是智慧型手機照片也能確保可靠的識別。大多數預處理和影像校正都是自動化的,僅在具有挑戰性的情況下才需要您的介入。您也可以預先定義要使用的影像區域。
設定傾斜校正的自訂角度並定義識別區域 - C++
string file = "photo.png";
AsposeOCRInput source;
source.url = file.c_str();
std::vector<AsposeOCRInput> content = { source };
// Fine-tune recognition
RecognitionSettings settings;
settings.detect_areas_mode = detect_areas_mode_enum::PHOTO;
// Extract text from the photo
auto result = asposeocr_recognize(content.data(), content.size(), settings);
// Output the recognized text
wchar_t* buffer = asposeocr_serialize_result(result, buffer_size, export_format::text);
std::wcout << std::wstring(buffer) << std::endl;
// Release the resources
asposeocr_free_result(result);
檢測影像缺陷
影像缺陷會嚴重影響 OCR 的準確性。它們可能是由影像擷取過程的品質、環境條件以及用於捕捉影像的硬體引起的。為了提高辨識準確性,有必要對影像進行預處理和增強,以盡可能減少這些缺陷。Aspose.OCR for C++ 可以在辨識過程中 自動尋找 潛在有問題的影像區域。您可以在預覽影像時突出顯示問題區域,甚至可以使用替代識別設定對其進行 OCR 以獲得更好的結果。
識別模糊、扭曲和低對比度圖像上的文字 - C++
// Provide the image
string file = "source.png";
AsposeOCRInput source;
source.url = file.c_str();
vector<AsposeOCRInput> content = {source};
// Activate detection of low-contrast areas
RecognitionSettings settings;
settings.defect_type = defect_type::ASPOSE_OCR_DETECT_DARK_IMAGES;
// Find and show low-contrast areas
AsposeOCRRecognitionResult result = asposeocr_recognize(content.data(), content.size(), settings);
for (size_t p_number = 0; p_number < result.pages_amount; ++p_number)
{
cout << "Page " << p_number << ";\n";
const auto& page = result.recognized_pages[p_number];
for (size_t defect_number = 0; defect_number < page.defects_count; ++defect_number)
{
const auto& defect_area = page.defect_areas[defect_number];
cout << "Low-contrast area " << defect_number << ":" << defect_area.area << std::endl;
}
}
// Release the resources
asposeocr_free_result(result);
批次處理
OCR API 提供各種批次方法,讓您可以在一次呼叫中識別多個圖像,讓您無需逐一識別每張圖像:
- 識別多頁 PDF 和 TIFF 檔案。
- 識別資料夾中的所有檔案。
- 識別存檔中的所有文件。
識別 ZIP 檔案 - C++
// Provide a ZIP archive
string file = "pages.zip";
AsposeOCRInput source;
source.url = file.c_str();
std::vector<AsposeOCRInput> content = { source };
// Fine-tune recognition
RecognitionSettings settings;
settings.detect_areas_mode = detect_areas_mode_enum::COMBINE;
// Extract texts
auto result = asposeocr_recognize(content.data(), content.size(), settings);