如何在 C# 中使用 Iron Tesseract
通过创建一个 IronTesseract 实例、配置语言和 OCR 设置,然后在包含您的图片或 PDF 的 OcrInput 对象上调用 Read() 方法来使用 C# 中的 Iron Tesseract。 这可以通过 Tesseract 5 的优化引擎将文字图像转换为可搜索的 PDF。
IronOCR 提供了一个直观的 API,用于使用定制和优化的 Tesseract 5,即 Iron Tesseract。 通过使用 IronOCR 和 IronTesseract,您能够将文字图像和扫描的文档转换为文字和可搜索的 PDF。 该库支持125种国际语言,并包含条形码阅读和计算机视觉等高级功能。
快速入门:在 C# 中设置 IronTesseract 配置
此示例展示了如何通过特定设置配置 IronTesseract 并在一行代码中执行 OCR。
-
使用 NuGet 包管理器安装 https://www.nuget.org/packages/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 库以读取图像
- 利用自定义 `Tesseract 5` 执行 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 支票时,您可以应用特定的预处理过滤器和区域检测来提高准确性。
财务文件配置示例:
:path=/static-assets/ocr/content-code-examples/how-to/iron-tesseract-6.cs
// 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.$,",
["textord_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.$,"},
{"textord_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 配置变量 | Default | 意义 |
|---|---|---|
| 分类_数量_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 | 0 | 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 | Use old baseline algorithm |
| 文本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 | 0 | All doc is proportial text |
| textord_debug_pitch_test | 0 | Debug on fixed pitch test |
| textord_disable_pitch_test | 0 | Turn off dp fixed pitch algorithm |
| textord_fast_pitch_test | 0 | Do even faster pitch algorithm |
| textord_debug_pitch_metric | 0 | Write full metric stuff |
| textord_show_row_cuts | 0 | Draw row-level cuts |
| textord_show_page_cuts | 0 | Draw page-level cuts |
| 文本ord_pitch_cheat | 0 | Use correct answer for fixed/prop |
| textord_blockndoc_fixed | 0 | Attempt whole doc/block fixed pitch |
| textord_show_initial_words | 0 | Display separate words |
| textord_show_new_words | 0 | Display separate words |
| textord_show_fixed_words | 0 | Display forced fixed pitch words |
| textord_blocksall_fixed | 0 | Moan about prop blocks |
| textord_blocksall_prop | 0 | Moan about fixed pitch blocks |
| textord_blocksall_testing | 0 | Dump stats when moaning |
| 文本测试模式 | 0 | Do current test |
| textord_pitch_rowsimilarity | 0.08 | Fraction of xheight for sameness |
| 单词首字母下调 | 0.5 | Max initial cluster size |
| 单词首字母上部 | 0.15 | Min initial cluster spacing |
| 单词默认值_prop_nonspace | 0.25 | Fraction of xheight |
| words_default_fixed_space | 0.75 | Fraction of xheight |
| 默认字数限制 | 0.6 | Allowed size variance |
| textord_words_definite_spread | 0.3 | Non-fuzzy spacing region |
| textord_spacesize_ratiofp | 2.8 | Min ratio space/nonspace |
| textord_spacesize_ratioprop | 2 | Min ratio space/nonspace |
| textord_fpiqr_ratio | 1.5 | Pitch IQR/Gap IQR threshold |
| textord_max_pitch_iqr | 0.2 | Xh fraction noise in pitch |
| textord_fp_min_width | 0.5 | Min width of decent blobs |
| 下划线偏移 | 0.1 | Fraction of x to ignore |
| 调试级别 | 0 | Debug level for unichar ambiguities |
| 分类调试级别 | 0 | Classify debug level |
| 分类规范方法 | 1 | Normalization Method ... |
| 匹配器调试级别 | 0 | Matcher Debug Level |
| 匹配器调试标志 | 0 | Matcher Debug Flags |
| 分类学习调试级别 | 0 | Learning Debug Level: |
| matcher_permanent_classes_min | 1 | Min # of permanent classes |
| matcher_min_examples_for_prototyping | 3 | Reliable Config Threshold |
| 用于原型设计的充分示例匹配器 | 5 | Enable adaption even if the ambiguities have not been seen |
| 分类_适应_原型_阈值 | 230 | Threshold for good protos during adaptive 0-255 |
| 分类_适应_特征_阈值 | 230 | Threshold for good features during adaptive 0-255 |
| 分类剪枝器阈值 | 229 | Class Pruner Threshold 0-255 |
| 分类剪枝乘数 | 15 | Class Pruner Multiplier 0-255: |
| 分类_cp_截止强度 | 7 | Class Pruner CutoffStrength: |
| 分类整数匹配器乘数 | 10 | Integer Matcher Multiplier 0-255: |
| dawg_debug_level | 0 | Set to 1 for general debug info, to 2 for more details, to 3 to see all the debug messages |
| 连字符调试级别 | 0 | Debug level for hyphenated words. |
| 小字体大小 | 2 | Size of dict word to be treated as non-dict word |
| stopper_debug_level | 0 | Stopper debug level |
| tessedit_truncate_wordchoice_log | 10 | Max words to keep in list |
| 最大置换尝试次数 | 10000 | Maximum number of different character choices to consider during permutation. This limit is especially useful when user patterns are specified, since overly generic patterns can result in dawg search exploring an overly large number of options. |
| 修复未切碎的斑点 | 1 | Fix blobs that aren't chopped |
| chop_debug | 0 | Chop debug |
| 分割长度 | 10000 | Split Length |
| 砍到相同距离 | 2 | Same distance |
| 砍伐最小轮廓点 | 6 | Min Number of Points on Outline |
| 剪缝绒毛尺寸 | 150 | Max number of seams in seam_pile |
| 切内角 | -50 | Min Inside Angle Bend |
| 砍掉最小轮廓区域 | 2000 | Min Outline Area |
| 截断居中最大宽度 | 90 | Width of (smaller) chopped blobs above which we don't care that a chop is not near the center. |
| 砍伐 x 和 y 重量 | 3 | X / Y length weight |
| wordrec_debug_level | 0 | Debug level for wordrec |
| wordrec_max_join_chunks | 4 | Max number of broken pieces to associate |
| segsearch_debug_level | 0 | SegSearch debug level |
| 搜索最大痛点 | 2000 | Maximum number of pain points stored in the queue |
| segsearch_max_futile_classifications | 20 | Maximum number of pain point classifications per chunk that did not result in finding a better word choice. |
| 语言模型调试级别 | 0 | Language model debug level |
| 语言模型语序 | 8 | Maximum order of the character ngram model |
| language_model_viterbi_list_max_num_prunable | 10 | Maximum number of prunable (those for which PrunablePath() is true) entries in each viterbi list recorded in BLOB_CHOICEs |
| 语言_模型_viterbi_list_max_size | 500 | Maximum size of viterbi lists recorded in BLOB_CHOICEs |
| 语言模型最小复合长度 | 3 | Minimum length of compound words |
| wordrec_display_segmentations | 0 | Display Segmentations |
| tessedit_pageseg_mode | 6 | Page seg mode: 0=osd only, 1=auto+osd, 2=auto_only, 3=auto, 4=column, 5=block_vert, 6=block, 7=line, 8=word, 9=word_circle, 10=char,11=sparse_text, 12=sparse_text+osd, 13=raw_line (Values from PageSegMode enum in tesseract/publictypes.h) |
| tessedit_ocr_engine_mode | 2 | Which OCR engine(s) to run (Tesseract, LSTM, both). Defaults to loading and running the most accurate available. |
| 页面eg_devanagari_split_strategy | 0 | Whether to use the top-line splitting process for Devanagari documents while performing page-segmentation. |
| ocr_devanagari_split_strategy | 0 | Whether to use the top-line splitting process for Devanagari documents while performing ocr. |
| 双向调试 | 0 | Debug level for BiDi |
| 应用框调试 | 1 | Debug level |
| 应用框_页面 | 0 | Page number to apply boxes from |
| tessedit_bigram_debug | 0 | Amount of debug output for bigram correction. |
| 调试噪声消除 | 0 | Debug reassignment of small outlines |
| 噪声最大值 | 8 | Max diacritics to apply to a blob |
| noise_maxperword | 16 | Max diacritics to apply to a word |
| 调试_x_ht_level | 0 | Reestimate debug |
| quality_min_initial_alphas_reqd | 2 | alphas in a good word |
| tessedit_tess_adaption_mode | 39 | Adaptation decision algorithm for tess |
| 多语言调试级别 | 0 | Print multilang debug info. |
| 段落调试级别 | 0 | Print paragraph debug info. |
| tessedit_preserve_min_wd_len | 2 | Only preserve wds longer than this |
| crunch_rating_max | 10 | For adj length in rating per ch |
| crunch_pot_指标 | 1 | How many potential indicators needed |
| crunch_leave_lc_strings | 4 | Don't crunch words with long lower case strings |
| crunch_leave_uc_strings | 4 | Don't crunch words with long lower case strings |
| 长时间重复训练 | 3 | Crunch words with long repetitions |
| crunch_debug | 0 | As it says |
| fixsp_non_noise_limit | 1 | How many non-noise blbs either side? |
| fixsp_done_mode | 1 | What constitues done for spacing |
| 调试修复空间级别 | 0 | Contextual fixspace debug |
| x_ht_acceptance_tolerance | 8 | Max allowed deviation of blob top outside of font data |
| x_ht_min_change | 8 | Min change in xht before actually trying it |
| 上标调试 | 0 | Debug level for sub & superscript fixer |
| jpg_质量 | 85 | Set JPEG quality level |
| 用户自定义DPI | 0 | Specify DPI for input image |
| 最小字符数 | 50 | Specify minimum characters to try during OSD |
| suspect_level | 99 | Suspect marker level |
| suspect_short_words | 2 | Don't suspect dict wds longer than this |
| tessedit_reject_mode | 0 | Rejection algorithm |
| tessedit_image_border | 2 | Rej blbs near image edge limit |
| 最小正常 x 高度像素 | 8 | Reject any x-ht lt or eq than this |
| 页码 | -1 | -1 -> All pages, else specific page to process |
| tessedit_parallelize | 1 | Run in parallel where possible |
| lstm_选择模式 | 2 | Allows to include alternative symbols choices in the hOCR output. Valid input values are 0, 1 and 2. 0 is the default value. With 1 the alternative symbol choices per timestep are included. With 2 alternative symbol choices are extracted from the CTC process instead of the lattice. The choices are mapped per character. |
| lstm_choice_iterations | 5 | Sets the number of cascading iterations for the Beamsearch in lstm_选择模式. Note that lstm_选择模式 must be set to a value greater than 0 to produce results. |
| tosp_debug_level | 0 | Debug data |
| tosp_enough_space_samples_for_median | 3 | or should we use mean |
| tosp_redo_kern_limit | 10 | No.samples reqd to reestimate for row |
| tosp_few_samples | 40 | No.gaps reqd with 1 large gap to treat as a table |
| tosp_短行 | 20 | No.gaps reqd with few cert spaces to use certs |
| tosp_sanity_method | 1 | How to avoid being silly |
| textord_max_noise_size | 7 | Pixel size of noise |
| 文本ord_baseline_debug | 0 | Baseline debug level |
| 文本ord_noise_sizefraction | 10 | Fraction of size for maxima |
| 文本ord_noise_translimit | 16 | Transitions for normal blob |
| 文本ord_noise_sncount | 1 | super norm blobs to save row |
| 使用歧义进行适应 | 0 | Use ambigs for deciding whether to adapt to a character |
| 优先划分 | 0 | Prioritize blob division over chopping |
| 分类启用学习 | 1 | Enable adaptive classifier |
| tess_cn_matching | 0 | Character Normalized Matching |
| tess_bn_matching | 0 | Baseline Normalized Matching |
| 启用自适应匹配器 | 1 | Enable adaptive classifier |
| 分类_使用_预先调整好的模板 | 0 | Use pre-adapted classifier templates |
| 分类_保存_已适配模板 | 0 | Save adapted templates to a file |
| 启用自适应调试器 | 0 | Enable match debugger |
| 分类非线性范数 | 0 | Non-linear stroke-density normalization |
| disable_character_fragments | 1 | Do not include character fragments in the results of the classifier |
| 分类调试字符片段 | 0 | Bring up graphical debugging windows for fragments training |
| Matcher_debug_separate_windows | 0 | Use two different windows for debugging the matching: One for the protos and one for the features. |
| 分类_bln_numeric_mode | 0 | Assume the input is numbers [0-9]. |
| 加载系统狗 | 1 | Load system word dawg. |
| 加载频率_dawg | 1 | Load frequent word dawg. |
| 加载无歧义的狗 | 1 | Load unambiguous word dawg. |
| 加载_punc_dawg | 1 | Load dawg with punctuation patterns. |
| 加载编号_dawg | 1 | Load dawg with number patterns. |
| 加载双字母狗 | 1 | Load dawg with special word bigrams. |
| 仅使用第一个 uft8_step | 0 | Use only the first UTF8 step of the given string when computing log probabilities. |
| stopper_no_acceptable_choices | 0 | Make AcceptableChoice() always return false. Useful when there is a need to explore all segmentations |
| 段非字母脚本 | 0 | Don't use any alphabetic-specific tricks. Set to true in the traineddata config file for scripts that are cursive or inherently fixed-pitch |
| 保存文档 | 0 | Save Document Words |
| 合并矩阵中的片段 | 1 | Merge the fragments in the ratings matrix and delete them after merging |
| wordrec_enable_assoc | 1 | Associator Enable |
| 强制word_assoc | 0 | force associator to run regardless of what enable_assoc is. This is used for CJK where component grouping is necessary. |
| 启用 | 1 | Chop enable |
| 垂直爬行 | 0 | Vertical creep |
| 砍新缝堆 | 1 | Use new seam_pile |
| 假设固定音高字符段 | 0 | include fixed-pitch heuristics in char segmentation |
| wordrec_skip_noo_truth_words | 0 | Only run OCR for words that had truth recorded in BlamerBundle |
| wordrec_debug_blamer | 0 | Print blamer debug messages |
| wordrec_run_blamer | 0 | Try to set the blame for errors |
| 保存备选方案 | 1 | Save alternative paths found during chopping and segmentation search |
| language_model_ngram_on | 0 | Turn on/off the use of character ngram model |
| language_model_ngram_use_ only_first_uft8_step | 0 | Use only the first UTF8 step of the given string when computing log probabilities. |
| language_model_ngram_space_delimited_language | 1 | Words are delimited by space |
| 语言_模型_使用_西格码_确定性 | 0 | Use sigmoidal score for certainty |
| tessedit_resegment_from_boxes | 0 | Take segmentation and labeling from box file |
| tessedit_resegment_from_line_boxes | 0 | Conversion of word/line box file to char box file |
| tessedit_train_from_boxes | 0 | Generate training data from boxed chars |
| tessedit_make_boxes_from_boxes | 0 | Generate more boxes from boxed chars |
| tessedit_train_line_recognizer | 0 | Break input into lines and remap boxes if present |
| tessedit_dump_pageseg_images | 0 | Dump intermediate images made during page segmentation |
| tessedit_doo_invert | 1 | Try inverting the image in LSTMRecognizeWord |
| tessedit_ambigs_training | 0 | Perform training for ambiguities |
| tessedit_adaption_debug | 0 | Generate and print debug information for adaption |
| applybox_learn_chars_and_char_frags_mode | 0 | Learn both character fragments (as is done in the special low exposure mode) as well as unfragmented characters. |
| applybox_learn_ngrams_mode | 0 | Each bounding box is assumed to contain ngrams. Only learn the ngrams whose outlines overlap horizontally. |
| tessedit_display_outwords | 0 | Draw output words |
| tessedit_dump_choices | 0 | Dump char choices |
| tessedit_timing_debug | 0 | Print timing stats |
| tessedit_fix_fuzzy_spaces | 1 | Try to improve fuzzy spaces |
| tessedit_unrej_any_wd | 0 | Don't bother with word plausibility |
| tessedit_fix_hyphens | 1 | Crunch double hyphens? |
| tessedit_enable_doc_dict | 1 | Add words to the document dictionary |
| tessedit_debug_fonts | 0 | Output font info per char |
| tessedit_debug_block_rejection | 0 | Block and Row stats |
| tessedit_enable_bigram_correction | 1 | Enable correction based on the word bigram dictionary. |
| tessedit_enable_dict_correction | 0 | Enable single word correction based on the dictionary. |
| 启用降噪 | 1 | Remove and conditionally reassign small outlines when they confuse layout analysis, determining diacritics vs noise |
| tessedit_minimal_rej_pass1 | 0 | Do minimal rejection on pass 1 output |
| tessedit_test_adaptation | 0 | Test adaption criteria |
| 测试点 | 0 | Test for point |
| 基于段落文本 | 1 | Run paragraph detection on the post-text-recognition (more accurate) |
| lstm_use_matrix | 1 | Use ratings matrix/beam search with lstm |
| tessedit_good_quality_unrej | 1 | Reduce rejection on good docs |
| tessedit_use_reject_spaces | 1 | Reject spaces? |
| tessedit_preserve_blk_rej_perfect_wds | 1 | Only rej partially rejected words in block rejection |
| tessedit_preserve_row_rej_perfect_wds | 1 | Only rej partially rejected words in row rejection |
| tessedit_dont_blkrej_good_wds | 0 | Use word segmentation quality metric |
| tessedit_dont_rowrej_good_wds | 0 | Use word segmentation quality metric |
| tessedit_row_rej_good_docs | 1 | Apply row rejection to good docs |
| tessedit_reject_bad_qual_wds | 1 | Reject all bad quality wds |
| tessedit_debug_doc_rejection | 0 | Page stats |
| tessedit_debug_quality_metrics | 0 | Output data to debug file |
| bland_unrej | 0 | unrej potential with no checks |
| unlv_tilde_crunching | 0 | Mark v.bad words for tilde crunch |
| 字体信息 | 0 | Add font info to hocr output |
| 文字框 | 0 | Add coordinates for each character to hocr output |
| crunch_early_merge_tess_fails | 1 | Before word crunch? |
| crunch_early_convert_bad_unlv_chs | 0 | Take out ~^ early? |
| crunch_terrible_garbage | 1 | As it says |
| crunch_leave_ok_strings | 1 | Don't touch sensible strings |
| crunch_accept_ok | 1 | Use acceptability in okstring |
| crunch_leave_accept_strings | 0 | Don't pot crunch sensible strings |
| crunch_include_numerals | 0 | Fiddle alpha figures |
| tessedit_prefer_joined_punct | 0 | Reward punctuation joins |
| tessedit_write_block_separators | 0 | Write block separators in output |
| tessedit_write_rep_codes | 0 | Write repetition char code |
| tessedit_write_unlv | 0 | Write .unlv output file |
| tessedit_create_txt | 0 | Write .txt output file |
| tessedit_create_hocr | 0 | Write .html hOCR output file |
| tessedit_create_alto | 0 | Write .xml ALTO file |
| tessedit_create_lstmbox | 0 | Write .box file for LSTM training |
| tessedit_create_tsv | 0 | Write .tsv output file |
| tessedit_create_wordstrbox | 0 | Write WordStr format .box output file |
| tessedit_create_pdf | 0 | Write .pdf output file |
| textonly_pdf | 0 | Create PDF with only one invisible text layer |
| suspect_constrain_1Il | 0 | UNLV keep 1Il chars rejected |
| tessedit_minimal_rejection | 0 | Only reject tess failures |
| tessedit_zero_rejection | 0 | Don't reject ANYTHING |
| tessedit_word_for_word | 0 | Make output have exactly one word per WERD |
| tessedit_zero_kelvin_rejection | 0 | Don't reject ANYTHING AT ALL |
| tessedit_rejection_debug | 0 | Adaption debug |
| tessedit_flip_0O | 1 | Contextual 0O O0 flips |
| rej_trust_doc_dawg | 0 | Use DOC dawg in 11l conf. detector |
| rej_1Il_use_dict_word | 0 | Use dictword test |
| rej_1Il_trust_permuter_type | 1 | Don't double check |
| rej_use_tess_accepted | 1 | Individual rejection control |
| rej_use_tess_blanks | 1 | Individual rejection control |
| rej_use_good_perm | 1 | Individual rejection control |
| rej_use_sensible_wd | 0 | Extend permuter check |
| rej_alphas_in_number_perm | 0 | Extend permuter check |
| tessedit_create_boxfile | 0 | Output text with boxes |
| tessedit_write_images | 0 | Capture the image from the IPE |
| 交互式显示模式 | 0 | Run interactively? |
| tessedit_override_permuter | 1 | According to dict_word |
| tessedit_use_primary_params_model | 0 | In multilingual mode use params model of the primary language |
| textord_tabfind_show_vlines | 0 | Debug line finding |
| textord_use_cjk_fp_model | 0 | Use CJK fixed pitch model |
| poly_allow_detailed_fx | 0 | Allow feature extractors to see the original outline |
| tessedit_init_config_only | 0 | Only initialize with the config file. Useful if the instance is not going to be used for OCR but say only for layout analysis. |
| 文本等式检测 | 0 | Turn on equation detector |
| textord_tabfind_vertical_text | 1 | Enable vertical detection |
| textord_tabfind_force_vertical_text | 0 | Force using vertical text page mode |
| 保留词间空格 | 0 | Preserve multiple interword spaces |
| pageseg_apply_music_mask | 1 | Detect music staff and remove intersecting components |
| textord_single_height_mode | 0 | Script has no xheight, so use a single mode |
| tosp_old_too_method | 0 | Space stats use prechopping? |
| tosp_old_to_constrain_sp_kn | 0 | Constrain relative values of inter and intra-word gaps for old_to_method. |
| tosp_only_use_prop_rows | 1 | Block stats to use fixed pitch rows? |
| tosp_force_wordbreak_on_punct | 0 | Force word breaks on punct to break long lines in non-space delimited langs |
| tosp_use_pre_chopping | 0 | Space stats use prechopping? |
| tosp_old_too_bug_fix | 0 | Fix suspected bug in old code |
| tosp_block_use_cert_spaces | 1 | Only stat OBVIOUS spaces |
| tosp_row_use_cert_spaces | 1 | Only stat OBVIOUS spaces |
| tosp_narrow_blobs_not_cert | 1 | Only stat OBVIOUS spaces |
| tosp_row_use_cert_spaces1 | 1 | Only stat OBVIOUS spaces |
| tosp_recovery_isolated_row_stats | 1 | Use row alone when inadequate cert spaces |
| tosp_only_small_gaps_for_kern | 0 | Better guess |
| tosp_all_flips_fuzzy | 0 | Pass ANY flip to context? |
| tosp_fuzzy_limit_all | 1 | Don't restrict kn->sp fuzzy limit to tables |
| 文本ord_no_rejects | 0 | Don't remove noise blobs |
| 文本ord_show_blobs | 0 | Display unsorted blobs |
| 文本框 | 0 | Display unsorted blobs |
| 文本ord_noise_rejwords | 1 | Reject noise-like words |
| 文本ord_noise_rejrows | 1 | Reject noise-like rows |
| 文本ord_noise_debug | 0 | Debug row garbage detector |
| 分类_学习_调试_str | Class str to debug learning | |
| 用户单词文件 | A filename of user-provided words. | |
| 用户词后缀 | A suffix of user-provided words located in tessdata. | |
| 用户模式文件 | A filename of user-provided patterns. | |
| 用户模式后缀 | A suffix of user-provided patterns located in tessdata. | |
| 输出歧义词文件 | Output file for ambiguities found in the dictionary | |
| 待调试单词 | Word for which stopper debug information should be printed to stdout | |
| tessedit_char_blacklist | Blacklist of chars not to recognize | |
| tessedit_char_whitelist | Whitelist of chars to recognize | |
| tessedit_char_unblacklist | List of chars to override tessedit_char_blacklist | |
| tessedit_write_params_to_file | Write all parameters to the given file. | |
| 应用框曝光模式 | .exp | Exposure value follows this pattern in the image filename. The name of the image files are expected to be in the form [lang].[fontname].exp [num].tif |
| chs_leading_punct('`" | 前导标点 | |
| chs_trailing_punct1 | ).,;:?! | 1st Trailing punctuation |
| chs_trailing_punct2)'`" | 2nd Trailing punctuation | |
| 轮廓_奇特 | %| | 非标准数量的轮廓 |
| 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 | List of languages to load with this one | |
| 页面分隔符 | Page separator (default is form feed control character) | |
| 分类字符规范范围 | 0.2 | Character Normalization Range ... |
| 分类最高评分率 | 1.5 | Veto ratio between classifier ratings |
| 分类最大确定性边际 | 5.5 | Veto difference between classifier certainties |
| 匹配器_良好阈值 | 0.125 | Good Match (0-1) |
| 匹配器可靠自适应结果 | 0 | Great Match (0-1) |
| 匹配器完美阈值 | 0.02 | Perfect Match (0-1) |
| Matcher_bad_match_pad | 0.15 | Bad Match Pad (0-1) |
| 匹配器评分差距 | 0.1 | New template margin (0-1) |
| 匹配器平均噪声大小 | 12 | Avg. noise blob length |
| Matcher_clustering_max_angle_delta | 0.015 | Maximum angle delta for prototype clustering |
| 分类不合格垃圾惩罚 | 0 | Penalty to apply when a non-alnum is vertically out of its expected textline position |
| 评分量表 | 1.5 | Rating scaling factor |
| 确定性规模 | 20 | Certainty scaling factor |
| tessedit_class_miss_scale | 0.00390625 | Scale factor for features not used |
| 分类适应剪枝因子 | 2.5 | Prune poor adapted results this much worse than best result |
| 分类适应剪枝阈值 | -1 | Threshold at which 分类适应剪枝因子 starts |
| 分类字符片段垃圾确定性阈值 | -3 | Exclude fragments that do not look like whole characters from training and adaption |
| 斑点大尺寸 | 0.3 | Max large speckle size |
| 斑点评级惩罚 | 10 | Penalty to add to worst rating for noise |
| x高度惩罚下标 | 0.125 | Score penalty (0.1 = 10%) added if there are subscripts or superscripts in a word, but it is otherwise OK. |
| x高度惩罚不一致 | 0.25 | Score penalty (0.1 = 10%) added if an xheight is inconsistent. |
| 词段惩罚字典_词频 | 1 | Score multiplier for word matches which have good case and are frequent in the given language (lower is better). |
| segment_penalty_dict_case_ok | 1.1 | Score multiplier for word matches that have good case (lower is better). |
| 段落_penalty_dict_case_bad | 1.3125 | Default score multiplier for word matches, which may have case issues (lower is better). |
| 段落_penalty_dict_nonword | 1.25 | Score multiplier for glyph fragment segmentations which do not match a dictionary word (lower is better). |
| 确定性规模 | 20 | Certainty scaling factor |
| stopper_nondict_certainty_base | -2.5 | Certainty threshold for non-dict words |
| stopper_phase2_certainty_rejection_offset | 1 | Reject certainty offset |
| stopper_certainty_per_char | -0.5 | Certainty to add for each dict char above small word size. |
| stopper_allowable_character_badness | 3 | Max certaintly variation allowed in a word (in sigma) |
| doc_dict_pending_threshold | 0 | Worst certainty for using pending dictionary |
| doc_dict_certainty_threshold | -2.25 | Worst certainty for words that can be inserted into the document dictionary |
| tessedit_certainty_threshold | -2.25 | Good blob limit |
| chop_split_dist_knob | 0.5 | Split length adjustment |
| chop_overlap_knob | 0.9 | Split overlap adjustment |
| chop_center_knob | 0.15 | Split center adjustment |
| chop_sharpness_knob | 0.06 | Split sharpness adjustment |
| chop_width_change_knob | 5 | Width change adjustment |
| chop_ok_split | 100 | OK split limit |
| chop_good_split | 50 | Good split limit |
| segsearch_max_char_wh_ratio(最大字符数比 | 2 | 最大字符宽高比 |
为获得最佳效果,建议在应用 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。
using 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 应用程序的兼容性。
IronOCR如何提高数据准确性?
IronOCR通过其高级识别算法和图像校正功能提高数据准确性,确保文本提取过程既可靠又精确。
IronOCR 有免费试用版吗?
是的,Iron Software 提供IronOCR 的免费试用,使用户在做出购买决定之前可以测试其功能和能力。

