如何在 C# 中使用 Iron Tesseract 实现 OCR识别与图片转文字
在 C# 中使用 Iron Tesseract 的方法是:创建一个 IronTesseract 实例,配置语言和 OCR识别设置,然后对包含图像或 PDF 的 OcrInput 对象调用 Read() 方法。 该程序使用 Tesseract 5 的优化引擎将图片转文字,实现光学字符识别,并输出可搜索的 PDF。
IronOCR 提供了一个直观的 API,用于使用定制和优化的 Tesseract 5,即 Iron Tesseract。 通过使用IronOCR和 IronTesseract,您可以将文本图像和扫描文档转换为文本和可搜索的 PDF。 该库支持125种国际语言,并包含条形码阅读和计算机视觉等高级功能。
快速入门:在 C# 中设置 IronTesseract 配置
本示例演示如何使用特定设置配置 IronTesseract 并在一行代码中执行 OCR。
-
使用 NuGet 包管理器安装 https://www.nuget.org/packages/IronOcr
PM > Install-Package IronOcr -
复制并运行这段代码。
var result = new IronOcr.IronTesseract { Language = IronOcr.OcrLanguage.English, Configuration = new IronOcr.TesseractConfiguration { ReadBarCodes = false, RenderSearchablePdf = true, WhiteListCharacters = "ABCabc123" } }.Read(new IronOcr.OcrInput("image.png")); -
部署到您的生产环境中进行测试
通过免费试用立即在您的项目中开始使用IronOCR
基本 OCR 工作流程
- 使用 NuGet 安装 OCR 库以读取图像
- Utilize Custom `Tesseract 5` to perform OCR
- 加载要处理的文档,例如图像或 PDF 文件
- 将提取的文本输出到控制台或文件
- 将结果保存为可搜索的 PDF
如何创建 IronTesseract 实例?
用这段代码初始化一个 Tesseract 对象:
:path=/static-assets/ocr/content-code-examples/how-to/irontesseract-initialize-irontesseract.cs
using IronOcr;
IronTesseract ocr = new IronTesseract();
Imports IronOcr
Dim ocr As New IronTesseract()
您可以通过选择不同的语言、启用条形码读取以及将字符列入白名单/黑名单来自定义 IronTesseract 的行为。 IronOCR 提供全面的配置选项,可对 OCR 流程进行微调:
:path=/static-assets/ocr/content-code-examples/how-to/irontesseract-configure-irontesseract.cs
IronTesseract ocr = new IronTesseract
{
Configuration = new TesseractConfiguration
{
ReadBarCodes = false,
RenderHocr = true,
TesseractVariables = null,
WhiteListCharacters = null,
BlackListCharacters = "`ë|^",
},
MultiThreaded = false,
Language = OcrLanguage.English,
EnableTesseractConsoleMessages = true, // False as default
};
Dim ocr As New IronTesseract With {
.Configuration = New TesseractConfiguration With {
.ReadBarCodes = False,
.RenderHocr = True,
.TesseractVariables = Nothing,
.WhiteListCharacters = Nothing,
.BlackListCharacters = "`ë|^"
},
.MultiThreaded = False,
.Language = OcrLanguage.English,
.EnableTesseractConsoleMessages = True
}
配置完成后,您可以使用 Tesseract 功能读取 OcrInput 对象。 OcrInput 类为加载各种输入格式提供了灵活的方法:
:path=/static-assets/ocr/content-code-examples/how-to/irontesseract-read.cs
IronTesseract ocr = new IronTesseract();
using OcrInput input = new OcrInput();
input.LoadImage("attachment.png");
OcrResult result = ocr.Read(input);
string text = result.Text;
Dim ocr As New IronTesseract()
Using input As New OcrInput()
input.LoadImage("attachment.png")
Dim result As OcrResult = ocr.Read(input)
Dim text As String = result.Text
End Using
对于复杂的场景,您可以利用多线程功能同时处理多个文档,从而显著提高批量操作的性能。
什么是高级 Tesseract 配置变量?
IronOCR Tesseract 接口允许通过IronOcr.TesseractConfiguration 类完全控制 Tesseract 配置变量。 通过这些高级设置,您可以针对特定用例优化 OCR 性能,例如 修复低质量扫描或 阅读特定文档类型。
如何在代码中使用 Tesseract 配置?
:path=/static-assets/ocr/content-code-examples/how-to/irontesseract-tesseract-configuration.cs
using IronOcr;
using System;
IronTesseract Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.English;
Ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.AutoOsd;
// Configure Tesseract Engine
Ocr.Configuration.TesseractVariables["tessedit_parallelize"] = false;
using var input = new OcrInput();
input.LoadImage("/path/file.png");
OcrResult Result = Ocr.Read(input);
Console.WriteLine(Result.Text);
Imports IronOcr
Imports System
Private Ocr As New IronTesseract()
Ocr.Language = OcrLanguage.English
Ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.AutoOsd
' Configure Tesseract Engine
Ocr.Configuration.TesseractVariables("tessedit_parallelize") = False
Dim input = New OcrInput()
input.LoadImage("/path/file.png")
Dim Result As OcrResult = Ocr.Read(input)
Console.WriteLine(Result.Text)
IronOCR 还针对不同的文档类型提供专门的配置。例如,在阅读护照或处理 MICR 支票时,您可以应用特定的预处理过滤器和区域检测来提高准确性。
财务文件配置示例:
// Example: Configure for financial documents
IronTesseract ocr = new IronTesseract
{
Language = OcrLanguage.English,
Configuration = new TesseractConfiguration
{
PageSegmentationMode = TesseractPageSegmentationMode.SingleBlock,
TesseractVariables = new Dictionary<string, object>
{
["tessedit_char_whitelist"] = "0123456789.$,",
["文本ord_heavy_nr"] = false,
["edges_max_children_per_outline"] = 10
}
}
};
// Apply preprocessing filters for better accuracy
using OcrInput input = new OcrInput();
input.LoadPdf("financial-document.pdf");
input.Deskew();
input.EnhanceResolution(300);
OcrResult result = ocr.Read(input);
// Example: Configure for financial documents
IronTesseract ocr = new IronTesseract
{
Language = OcrLanguage.English,
Configuration = new TesseractConfiguration
{
PageSegmentationMode = TesseractPageSegmentationMode.SingleBlock,
TesseractVariables = new Dictionary<string, object>
{
["tessedit_char_whitelist"] = "0123456789.$,",
["文本ord_heavy_nr"] = false,
["edges_max_children_per_outline"] = 10
}
}
};
// Apply preprocessing filters for better accuracy
using OcrInput input = new OcrInput();
input.LoadPdf("financial-document.pdf");
input.Deskew();
input.EnhanceResolution(300);
OcrResult result = ocr.Read(input);
Imports IronOcr
' Example: Configure for financial documents
Dim ocr As New IronTesseract With {
.Language = OcrLanguage.English,
.Configuration = New TesseractConfiguration With {
.PageSegmentationMode = TesseractPageSegmentationMode.SingleBlock,
.TesseractVariables = New Dictionary(Of String, Object) From {
{"tessedit_char_whitelist", "0123456789.$,"},
{"文本ord_heavy_nr", False},
{"edges_max_children_per_outline", 10}
}
}
}
' Apply preprocessing filters for better accuracy
Using input As New OcrInput()
input.LoadPdf("financial-document.pdf")
input.Deskew()
input.EnhanceResolution(300)
Dim result As OcrResult = ocr.Read(input)
End Using
所有 Tesseract 配置变量的完整列表是什么?
这些可以通过 IronTesseract.Configuration.TesseractVariables["key"] = value; 进行设置。 配置变量允许您对 OCR 行为进行微调,以便在处理特定文档时获得最佳效果。 有关优化 OCR 性能的详细指导,请参阅我们的快速 OCR 配置指南。
| Tesseract 配置变量 | 默认 | 意义 |
|---|---|---|
| 分类_数量_cp_级别 | 3 | 类剪枝器级别数 |
| textord_debug_tabfind | 0 | 调试选项卡查找 |
| textord_debug_bugs | 0 | 启用与制表符查找错误相关的输出 |
| textord_testregion_left | -1 | 调试报告矩形的左边缘 |
| textord_testregion_top | -1 | 调试报告矩形的顶部边缘 |
| 文本ord_测试区域_右侧 | 2147483647 | 调试矩形的右边缘 |
| textord_testregion_bottom | 2147483647 | 调试矩形的底部边缘 |
| textord_tabfind_show_partitions | 0 | 显示分区边界,如果大于 1 则等待。 |
| 拆分调试级别 | 0 | 拆分 shiro-rekha 进程的调试级别。 |
| edges_max_children_per_outline | 10 | 角色轮廓内子角色的最大数量 |
| 边缘_最大子层 | 5 | 角色轮廓内嵌套子角色的最大层数 |
| 每个孙子的边缘子节点 | 10 | 抛掷轮廓的重要性比率 |
| 边缘子数量限制 | 45 | 斑点中允许的最大孔数 |
| 边缘_最小_无孔 | 12 | 方框内潜在字符的最小像素 |
| 边缘路径面积比率 | 40 | Max lensq/area for acceptable child outline |
| textord_fp_chop_error | 2 | 最大允许的切割单元弯曲度 |
| textord_tabfind_show_images | 0 | Show image blobs |
| textord_skewsmooth_offset | 4 | 对于平滑因子 |
| textord_skewsmooth_offset2 | 1 | 对于平滑因子 |
| textord_test_x | -2147483647 | 测试点坐标 |
| textord_test_y | -2147483647 | 测试点坐标 |
| textword_min_blobs_in_row | 4 | 梯度计数前的最小斑点数 |
| 文本ord_spline_minblobs | 8 | Min blobs in each spline segment |
| 文本ord_spline_medianwin | 6 | Size of window for spline segmentation |
| textord_max_blob_overlaps | 4 | Max number of blobs a big blob can overlap |
| textord_min_xheight | 10 | Min credible pixel xheight |
| textord_lms_line_trials | 12 | Number of linew fits to do |
| oldbl_holed_losscount | 10 | Max lost before fallback line used |
| pitsync_linear_version | 6 | Use new fast algorithm |
| pitsync_fake_depth | 1 | Max advance fake generation |
| textord_tabfind_show_strokewidths | 0 | Show stroke widths |
| 文本ord_dotmatrix_gap | 3 | Max pixel gap for broken pixed pitch |
| textord_debug_block | 0 | Block to do debug on |
| 文本音调范围 | 2 | Max range test on pitch |
| textord_words_veto_power | 5 | Rows required to outvote a veto |
| equationdetect_save_bi_image | 0 | Save input bi image |
| equationdetect_save_spt_image | 0 | Save special character image |
| 方程检测保存种子图像 | 0 | Save the seed image |
| 方程检测保存合并图像 | 0 | Save the merged image |
| poly_debug | 0 | Debug old poly |
| poly_wide_objects_better | 1 | More accurate approx on wide things |
| wordrec_display_splits | 0 | Display splits |
| textord_debug_printable | 0 | Make debug windows printable |
| textord_space_size_is_variable | 0 | If true, word delimiter spaces are assumed to have variable width, even though characters have fixed pitch. |
| textord_tabfind_show_initial_partitions | 0 | Show partition bounds |
| textord_tabfind_show_reject_blobs | 0 | Show blobs rejected as noise |
| textord_tabfind_show_columns | 0 | Show column bounds |
| textord_tabfind_show_blocks | 0 | Show final block bounds |
| textord_tabfind_find_tables | 1 | run table detection |
| 拆分调试图像 | 0 | Whether to create a debug image for split shiro-rekha process. |
| textord_show_fixed_cuts | 0 | Draw fixed pitch cell boundaries |
| 边缘使用新的轮廓复杂性 | 0 | Use the new outline complexity module |
| 边缘调试 | 0 | turn on debugging for this module |
| 边缘_子类_修复 | 0 | Remove boxy parents of char-like children |
| gapmap_debug | 0 | Say which blocks have tables |
| gapmap_use_ends | 0 | Use large space at start and end of rows |
| gapmap_noo_isolated_quanta | 0 | Ensure gaps not less than 2quanta wide |
| 文本ord_heavy_nr | 0 | Vigorously remove noise |
| textord_show_initial_rows | 0 | Display row accumulation |
| textord_show_parallel_rows | 0 | Display page correlated rows |
| textord_show_expanded_rows | 0 | Display rows after expanding |
| textord_show_final_rows | 0 | Display rows after final fitting |
| 文本ord_show_final_blobs | Display blob bounds after pre-ass | |
| textord_test_landscape | 0 | Tests refer to land/port |
| textord_parallel_baselines | 1 | Force parallel baselines |
| textord_straight_baselines | 0 | Force straight baselines |
| 旧基线 | 1 | |
| 文本ord_old_xheight | 0 | Use old xheight algorithm |
| textord_fix_xheight_bug | 1 | Use spline baseline |
| textord_fix_makerow_bug | 1 | Prevent multiple baselines |
| textord_debug_xheights | 0 | Test xheight algorithms |
| textord_biased_skewcalc | 1 | Bias skew estimates with line length |
| textord_interpolating_skew | 1 | Interpolate across gaps |
| textord_new_initial_xheight | 1 | Use test xheight mechanism |
| textord_debug_blob | 0 | Print test blob information |
| textord_really_old_xheight | 0 | Use original wiseowl xheight |
| textord_oldbl_debug | 0 | Debug old baseline generation |
| textord_debug_baselines | 0 | Debug baseline generation |
| textord_oldbl_paradef | 1 | Use para default mechanism |
| textord_oldbl_split_splines | 1 | Split stepped splines |
| textord_oldbl_merge_parts | 1 | Merge suspect partitions |
| 旧版本 | 1 | Improve correlation of heights |
| oldbl_xhfix | 0 | Fix bug in modes threshold for xheights |
| textord_ocropus_mode | 0 | Make baselines for ocropus |
| textord_tabfind_only_strokewidths | 0 | Only run stroke widths |
| textord_tabfind_show_initialtabs | 0 | Show tab candidates |
| textord_tabfind_show_finaltabs | 0 | Show tab vectors |
| textord_show_tables | 0 | Show table regions |
| textord_tablefind_show_mark | 0 | Debug table marking steps in detail |
| textord_tablefind_show_stats | 0 | Show page stats used in table finding |
| textord_tablefind_recognize_tables | 0 | Enables the table recognizer for table layout and filtering. |
| textord_all_prop | ||
| textord_debug_pitch_test | ||
| textord_disable_pitch_test | ||
| textord_fast_pitch_test | ||
| textord_debug_pitch_metric | ||
| textord_show_row_cuts | ||
| textord_show_page_cuts | ||
| 文本ord_pitch_cheat | ||
| textord_blockndoc_fixed | ||
| textord_show_initial_words | ||
| textord_show_new_words | ||
| textord_show_fixed_words | ||
| textord_blocksall_fixed | ||
| textord_blocksall_prop | ||
| textord_blocksall_testing | ||
| 文本测试模式 | ||
| textord_pitch_rowsimilarity | ||
| 单词首字母下调 | ||
| 单词首字母上部 | ||
| 单词默认值_prop_nonspace | ||
| words_default_fixed_space | ||
| 默认字数限制 | ||
| textord_words_definite_spread | ||
| textord_spacesize_ratiofp | ||
| textord_spacesize_ratioprop | ||
| textord_fpiqr_ratio | ||
| textord_max_pitch_iqr | ||
| textord_fp_min_width | ||
| 下划线偏移 | ||
| 调试级别 | ||
| 分类调试级别 | ||
| 分类规范方法 | ||
| 匹配器调试级别 | ||
| 匹配器调试标志 | ||
| 分类学习调试级别 | ||
| matcher_permanent_classes_min | ||
| matcher_min_examples_for_prototyping | ||
| 用于原型设计的充分示例匹配器 | ||
| 分类_适应_原型_阈值 | ||
| 分类_适应_特征_阈值 | ||
| 分类剪枝器阈值 | ||
| 分类剪枝乘数 | ||
| 分类_cp_截止强度 | ||
| 分类整数匹配器乘数 | ||
| dawg_debug_level | ||
| 连字符调试级别 | ||
| 小字体大小 | ||
| stopper_debug_level | ||
| tessedit_truncate_wordchoice_log | ||
| 最大置换尝试次数 | ||
| 修复未切碎的斑点 | ||
| chop_debug | ||
| 分割长度 | ||
| 砍到相同距离 | ||
| 砍伐最小轮廓点 | ||
| 剪缝绒毛尺寸 | ||
| 切内角 | ||
| 砍掉最小轮廓区域 | ||
| 截断居中最大宽度 | ||
| 砍伐 x 和 y 重量 | ||
| wordrec_debug_level | ||
| wordrec_max_join_chunks | ||
| segsearch_debug_level | ||
| 搜索最大痛点 | ||
| segsearch_max_futile_classifications | ||
| 语言模型调试级别 | ||
| 语言模型语序 | ||
| language_model_viterbi_list_max_num_prunable | ||
| 语言_模型_viterbi_list_max_size | ||
| 语言模型最小复合长度 | ||
| wordrec_display_segmentations | ||
| tessedit_pageseg_mode | ||
| tessedit_ocr_engine_mode | ||
| 页面eg_devanagari_split_strategy | ||
| ocr_devanagari_split_strategy | ||
| 双向调试 | ||
| 应用框调试 | ||
| 应用框_页面 | ||
| tessedit_bigram_debug | ||
| 调试噪声消除 | ||
| 噪声最大值 | ||
| noise_maxperword | ||
| 调试_x_ht_level | ||
| quality_min_initial_alphas_reqd | ||
| tessedit_tess_adaption_mode | ||
| 多语言调试级别 | ||
| 段落调试级别 | ||
| tessedit_preserve_min_wd_len | ||
| crunch_rating_max | ||
| crunch_pot_指标 | ||
| crunch_leave_lc_strings | ||
| crunch_leave_uc_strings | ||
| 长时间重复训练 | ||
| crunch_debug | ||
| fixsp_non_noise_limit | ||
| fixsp_done_mode | ||
| 调试修复空间级别 | ||
| x_ht_acceptance_tolerance | ||
| x_ht_min_change | ||
| 上标调试 | ||
| jpg_质量 | ||
| 用户自定义DPI | ||
| 最小字符数 | ||
| suspect_level | ||
| suspect_short_words | ||
| tessedit_reject_mode | ||
| tessedit_image_border | ||
| 最小正常 x 高度像素 | ||
| 页码 | ||
| tessedit_parallelize | ||
| lstm_选择模式 | ||
| lstm_choice_iterations | ||
| tosp_debug_level | ||
| tosp_enough_space_samples_for_median | ||
| tosp_redo_kern_limit | ||
| tosp_few_samples | ||
| tosp_短行 | ||
| tosp_sanity_method | ||
| textord_max_noise_size | ||
| 文本ord_baseline_debug | ||
| 文本ord_noise_sizefraction | ||
| 文本ord_noise_translimit | ||
| 文本ord_noise_sncount | ||
| 使用歧义进行适应 | ||
| 优先划分 | ||
| 分类启用学习 | ||
| tess_cn_matching | ||
| tess_bn_matching | ||
| 启用自适应匹配器 | ||
| 分类_使用_预先调整好的模板 | ||
| 分类_保存_已适配模板 | ||
| 启用自适应调试器 | ||
| 分类非线性范数 | ||
| disable_character_fragments | ||
| 分类调试字符片段 | ||
| Matcher_debug_separate_windows | ||
| 分类_bln_numeric_mode | ||
| 加载系统狗 | ||
| 加载频率_dawg | ||
| 加载无歧义的狗 | ||
| 加载_punc_dawg | ||
| 加载编号_dawg | ||
| 加载双字母狗 | ||
| 仅使用第一个 uft8_step | ||
| stopper_no_acceptable_choices | ||
| 段非字母脚本 | ||
| 保存文档 | ||
| 合并矩阵中的片段 | ||
| wordrec_enable_assoc | ||
| 强制word_assoc | ||
| 启用 | ||
| 垂直爬行 | ||
| 砍新缝堆 | ||
| 假设固定音高字符段 | ||
| wordrec_skip_noo_truth_words | ||
| wordrec_debug_blamer | ||
| wordrec_run_blamer | ||
| 保存备选方案 | ||
| language_model_ngram_on | ||
| language_model_ngram_use_
only_first_uft8_step | ||
| language_model_ngram_space_delimited_language | ||
| 语言_模型_使用_西格码_确定性 | ||
| tessedit_resegment_from_boxes | ||
| tessedit_resegment_from_line_boxes | ||
| tessedit_train_from_boxes | ||
| tessedit_make_boxes_from_boxes | ||
| tessedit_train_line_recognizer | ||
| tessedit_dump_pageseg_images | ||
| tessedit_doo_invert | ||
| tessedit_ambigs_training | ||
| tessedit_adaption_debug | ||
| applybox_learn_chars_and_char_frags_mode | ||
| applybox_learn_ngrams_mode | ||
| tessedit_display_outwords | ||
| tessedit_dump_choices | ||
| tessedit_timing_debug | ||
| tessedit_fix_fuzzy_spaces | ||
| tessedit_unrej_any_wd | ||
| tessedit_fix_hyphens | ||
| tessedit_enable_doc_dict | ||
| tessedit_debug_fonts | ||
| tessedit_debug_block_rejection | ||
| tessedit_enable_bigram_correction | ||
| tessedit_enable_dict_correction | ||
| 启用降噪 | ||
| tessedit_minimal_rej_pass1 | ||
| tessedit_test_adaptation | ||
| 测试点 | ||
| 基于段落文本 | ||
| lstm_use_matrix | ||
| tessedit_good_quality_unrej | ||
| tessedit_use_reject_spaces | ||
| tessedit_preserve_blk_rej_perfect_wds | ||
| tessedit_preserve_row_rej_perfect_wds | ||
| tessedit_dont_blkrej_good_wds | ||
| tessedit_dont_rowrej_good_wds | ||
| tessedit_row_rej_good_docs | ||
| tessedit_reject_bad_qual_wds | ||
| tessedit_debug_doc_rejection | ||
| tessedit_debug_quality_metrics | ||
| bland_unrej | ||
| unlv_tilde_crunching | ||
| 字体信息 | ||
| 文字框 | ||
| crunch_early_merge_tess_fails | ||
| crunch_early_convert_bad_unlv_chs | ||
| crunch_terrible_garbage | ||
| crunch_leave_ok_strings | ||
| crunch_accept_ok | ||
| crunch_leave_accept_strings | ||
| crunch_include_numerals | ||
| tessedit_prefer_joined_punct | ||
| tessedit_write_block_separators | ||
| tessedit_write_rep_codes | ||
| tessedit_write_unlv | ||
| tessedit_create_txt | ||
| tessedit_create_hocr | ||
| tessedit_create_alto | ||
| tessedit_create_lstmbox | ||
| tessedit_create_tsv | ||
| tessedit_create_wordstrbox | ||
| tessedit_create_pdf | ||
| textonly_pdf | ||
| suspect_constrain_1Il | ||
| tessedit_minimal_rejection | ||
| tessedit_zero_rejection | ||
| tessedit_word_for_word | ||
| tessedit_zero_kelvin_rejection | ||
| tessedit_rejection_debug | ||
| tessedit_flip_0O | ||
| rej_trust_doc_dawg | ||
| rej_1Il_use_dict_word | ||
| rej_1Il_trust_permuter_type | ||
| rej_use_tess_accepted | ||
| rej_use_tess_blanks | ||
| rej_use_good_perm | ||
| rej_use_sensible_wd | ||
| rej_alphas_in_number_perm | ||
| tessedit_create_boxfile | ||
| tessedit_write_images | ||
| 交互式显示模式 | ||
| tessedit_override_permuter | ||
| tessedit_use_primary_params_model | ||
| textord_tabfind_show_vlines | ||
| textord_use_cjk_fp_model | ||
| poly_allow_detailed_fx | ||
| tessedit_init_config_only | ||
| 文本等式检测 | ||
| textord_tabfind_vertical_text | ||
| textord_tabfind_force_vertical_text | ||
| 保留词间空格 | ||
| pageseg_apply_music_mask | ||
| textord_single_height_mode | ||
| tosp_old_too_method | ||
| tosp_old_to_constrain_sp_kn | ||
| tosp_only_use_prop_rows | ||
| tosp_force_wordbreak_on_punct | ||
| tosp_use_pre_chopping | ||
| tosp_old_too_bug_fix | ||
| tosp_block_use_cert_spaces | ||
| tosp_row_use_cert_spaces | ||
| tosp_narrow_blobs_not_cert | ||
| tosp_row_use_cert_spaces1 | ||
| tosp_recovery_isolated_row_stats | ||
| tosp_only_small_gaps_for_kern | ||
| tosp_all_flips_fuzzy | ||
| tosp_fuzzy_limit_all | ||
| 文本ord_no_rejects | ||
| 文本ord_show_blobs | ||
| 文本框 | ||
| 文本ord_noise_rejwords | ||
| 文本ord_noise_rejrows | ||
| 文本ord_noise_debug | ||
| 分类_学习_调试_str | ||
| 用户单词文件 | ||
| 用户词后缀 | ||
| 用户模式文件 | ||
| 用户模式后缀 | ||
| 输出歧义词文件 | ||
| 待调试单词 | ||
| tessedit_char_blacklist | ||
| tessedit_char_whitelist | ||
| tessedit_char_unblacklist | ||
| tessedit_write_params_to_file | ||
| 应用框曝光模式 | ||
| chs_leading_punct('`" | ||
| chs_trailing_punct1 | ||
| chs_trailing_punct2)'`" | ||
| 轮廓_奇特 | %| | 非标准数量的轮廓 |
| outlines_2ij!?%":; | 非标准数量的轮廓 | |
| 数字标点符号 | ., | Punct. chs expected WITHIN numbers |
| 未识别的字符 | | | Output char for unidentified blobs |
| ok_repeated_ch_non_alphanum_wds | -?*= | Allow NN to unrej |
| 冲突集 I_l_1 | Il1 [] | Il1 conflict set |
| 文件类型 | .tif | Filename extension |
| tessedit_load_sublangs | ||
| 页面分隔符 | ||
| 分类字符规范范围 | ||
| 分类最高评分率 | ||
| 分类最大确定性边际 | ||
| 匹配器_良好阈值 | ||
| 匹配器可靠自适应结果 | ||
| 匹配器完美阈值 | ||
| Matcher_bad_match_pad | ||
| 匹配器评分差距 | ||
| 匹配器平均噪声大小 | ||
| Matcher_clustering_max_angle_delta | ||
| 分类不合格垃圾惩罚 | ||
| 评分量表 | ||
| 确定性规模 | ||
| tessedit_class_miss_scale | ||
| 分类适应剪枝因子 | ||
| 分类适应剪枝阈值 | ||
| 分类字符片段垃圾确定性阈值 | ||
| 斑点大尺寸 | ||
| 斑点评级惩罚 | ||
| x高度惩罚下标 | ||
| x高度惩罚不一致 | ||
| 词段惩罚字典_词频 | ||
| segment_penalty_dict_case_ok | ||
| 段落_penalty_dict_case_bad | ||
| 段落_penalty_dict_nonword | ||
| 确定性规模 | ||
| stopper_nondict_certainty_base | ||
| stopper_phase2_certainty_rejection_offset | ||
| stopper_certainty_per_char | ||
| stopper_allowable_character_badness | ||
| doc_dict_pending_threshold | ||
| doc_dict_certainty_threshold | ||
| tessedit_certainty_threshold | ||
| chop_split_dist_knob | ||
| chop_overlap_knob | ||
| chop_center_knob | ||
| chop_sharpness_knob | ||
| chop_width_change_knob | ||
| chop_ok_split | ||
| chop_good_split | ||
| segsearch_max_char_wh_ratio(最大字符数比 |
为获得最佳效果,建议在应用 OCR 之前使用 IronOCR 的图像预处理过滤器。 这些过滤器可以显著提高准确性,尤其是在处理 低质量扫描或 表格等复杂文档时。
常见问题解答
如何在 C# 中配置用于 OCR 的 IronTesseract?
要配置 IronTesseract,请创建一个 IronTesseract 实例并设置语言和配置等属性。您可以指定 OCR 语言(从 125 种支持语言中选择)、启用条形码读取、配置可搜索 PDF 输出以及设置字符白名单。例如: var tesseract = new IronOcr.IronTesseract { Language = IronOcr.OcrLanguage.English, Configuration = new IronOcr.TesseractConfiguration { ReadBarCodes = false, RenderSearchablePdf = true }; var tesseract = new IronOcr.IronTesseract { Language = IronOcr.OcrLanguage.English, Configuration = new IronOcr.TesseractConfiguration { ReadBarCodes = false, RenderSearchablePdf = true };。};
IronTesseract 支持哪些输入格式?
IronTesseract 可通过 OcrInput 类接受各种输入格式。您可以处理图像(PNG、JPG 等)、PDF 文件和扫描文档。OcrInput 类为加载这些不同的格式提供了灵活的方法,使您可以轻松地在几乎所有包含文本的文档上执行 OCR。
使用 IronTesseract 能否在阅读文本的同时阅读 BarCode?
是的,IronTesseract 包含高级条形码读取功能。您可以通过在 TesseractConfiguration 中设置 ReadBarCodes = true 来启用条形码检测功能。这样,您就可以在一次 OCR 操作中从同一文档中提取文本和条形码数据。
如何从扫描文件创建可搜索的 PDF?
通过在 TesseractConfiguration 中设置 RenderSearchablePdf = true,IronTesseract 可以将扫描的文档和图像转换为可搜索的 PDF。这样创建的 PDF 文件中的文本是可选择和可搜索的,同时保持了原始文档的外观。
IronTesseract 的 OCR 支持哪些语言?
IronTesseract 支持 125 种国际语言的文本识别。您可以通过设置 IronTesseract 实例的语言属性来指定语言,如 IronOcr.OcrLanguage.English、Spanish、Chinese、Arabic 等。
能否限制 OCR 识别的字符?
是的,IronTesseract 允许通过 TesseractConfiguration 中的 WhiteListCharacters 属性将字符列入白名单和黑名单。当您知道预期的字符集时,该功能有助于提高准确性,例如只限于识别字母数字字符。
如何同时对多个文档执行 OCR?
IronTesseract 支持批处理的多线程功能。您可以利用并行处理功能同时对多个文档进行 OCR 识别,从而显著提高处理大量图像或 PDF 文件时的性能。
IronOCR 使用哪个版本的 Tesseract?
IronOCR 使用经过定制和优化的 Tesseract 5 版本,即 Iron Tesseract。与标准 Tesseract 实现相比,这一增强型引擎提高了准确性和性能,同时保持了与 .NET 应用程序的兼容性。

