Build, debug, and write code for projects using the Tesseract.NET wrapper (charlesw/tesseract v5.2.0). Trigger whenever the user: mentions tesseract OCR in a .NET/C# context; asks about TesseractEngine, Pix, Page, ResultIterator APIs; encounters DllNotFoundException or native interop errors with tesseract/leptonica; needs to build specific TFMs (netstandard2.0/net47/net48); writes OCR pipelines in C#; or works with P/Invoke/InteropDotNet patterns in a tesseract wrapper project. Also trigger when the user needs to troubleshoot tessdata paths, engine initialization, cross-platform DLL resolution, or packaging native binaries with a .NET library. Use this skill even if the user doesn't explicitly name "tesseract.NET" — any .NET OCR task with tesseract references or native interop loading tesseract50/leptonica-1.82.0 should trigger.
Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
Build, debug, and write code for projects using the Tesseract.NET wrapper (charlesw/tesseract v5.2.0). Trigger whenever the user: mentions tesseract OCR in a .NET/C# context; asks about TesseractEngine, Pix, Page, ResultIterator APIs; encounters DllNotFoundException or native interop errors with tesseract/leptonica; needs to build specific TFMs (netstandard2.0/net47/net48); writes OCR pipelines in C#; or works with P/Invoke/InteropDotNet patterns in a tesseract wrapper project. Also trigger when the user needs to troubleshoot tessdata paths, engine initialization, cross-platform DLL resolution, or packaging native binaries with a .NET library. Use this skill even if the user doesn't explicitly name "tesseract.NET" — any .NET OCR task with tesseract references or native interop loading tesseract50/leptonica-1.82.0 should trigger.
Tesseract.NET Wrapper Skill
Guide for building, debugging, and developing with the Tesseract.NET wrapper (v5.2.0) wrapping tesseract C++ 5.2.0.
Tessdoc is available locally at tessdoc/ — see tessdoc/ImproveQuality.md, tessdoc/FAQ.md, tessdoc/Common-Errors-and-Resolutions.md, tessdoc/APIExample.md, tessdoc/Data-Files.md, tessdoc/Command-Line-Usage.md, and tessdoc/InputFormats.md for detailed upstream documentation.
// After SetImage in native API, call SetRectangle before Recognize.// In .NET wrapper, use engine.Process(img, pageSegMode, rect)var rect = new Rect(x: 30, y: 86, width: 590, height: 100);
usingvar page = engine.Process(img, rect);
usingvar page = engine.Process(img);
usingvar iter = page.GetIterator();
iter.Begin();
do {
string word = iter.GetText(PageIteratorLevel.Word);
float conf = iter.GetConfidence(PageIteratorLevel.Word);
iter.TryGetBoundingBox(PageIteratorLevel.Word, out Rect rect);
var attrs = iter.GetWordFontAttributes();
} while (iter.Next(PageIteratorLevel.Word));
ChoiceIterator (alternative symbol hypotheses)
usingvar iter = page.GetIterator();
iter.Begin();
do {
if (iter.GetText(PageIteratorLevel.Symbol) != null) {
usingvar choices = iter.GetChoiceIterator();
do {
string alt = choices.GetText();
float conf = choices.GetConfidence();
} while (choices.Next());
}
} while (iter.Next(PageIteratorLevel.Symbol));
// Character whitelist (digits only)
engine.SetVariable("tessedit_char_whitelist", "0123456789");
// Page segmentation mode
engine.SetVariable("tessedit_pageseg_mode", "6"); // PSM_SINGLE_BLOCK// Disable dictionary (for non-dictionary text like codes)
engine.SetVariable("load_system_dawg", "0");
engine.SetVariable("load_freq_dawg", "0");
// Debug output file
engine.SetDebugVariable("debug_file", "tesseract.log");
// Disable adaptive classifier (for consistent multi-image results)
engine.SetVariable("classify_enable_learning", "0");
// LSTM alternative symbol choices (requires LSTMs)
engine.SetVariable("lstm_choice_mode", "2");
// Disable image inversion (speed gain)
engine.SetVariable("tessedit_do_invert", "0");
// Thread control (OMP_THREAD_LIMIT env var, not a SetVariable)
Page layout analysis (OSD)
usingvar layout = page.AnalyseLayout();
layout.Begin();
do {
PolyBlockType type = layout.BlockType;
if (layout.TryGetBoundingBox(PageIteratorLevel.Block, out Rect bb))
Console.WriteLine($"Block {type} at ({bb.X},{bb.Y}) {bb.Width}x{bb.Height}");
var props = layout.GetProperties();
// Orientation, WritingDirection, TextLineOrder, DeskewAngle
} while (layout.Next(PageIteratorLevel.Block));
Multi-page TIFF
Pix img = null;
int offset = 0;
while ((img = Pix.pixReadFromMultipageTiff(path, ref offset)) != null) {
using (img) {
usingvar page = engine.Process(img);
string text = page.GetText();
}
}
Multiple languages
// "+" separated language codesusingvar engine = new TesseractEngine("./tessdata", "eng+deu", EngineMode.Default);
Image Quality & OCR Accuracy
Based on tessdoc/ImproveQuality.md. See that file for full details.
Critical factors
DPI ≥ 300 — rescale if needed. Optimal capital letter height suggested by Willus Dotkom.
Dark text on light background — tesseract 4+ handles dark-on-light only. Invert if needed.
Binarization — tesseract uses Otsu internally. Tesseract 5 adds Adaptive Otsu and Sauvola via thresholding_* config params. Can also preprocess with Leptonica in code (BinarizeOtsuAdaptiveThreshold, BinarizeSauvola).
Noise — use Despeckle() or preprocess with ImageMagick/OpenCV.
Rotation/deskew — even slight skew degrades line segmentation. Use Deskew() or preprocess.
Borders — too little border → segmentation issues. Too much border → "empty page". Add ~10px white border if tightly cropped.
Alpha channel — tesseract 4+ blends with white background. For problematic cases (subtitles), remove alpha beforehand.
Page segmentation modes
PSM directly corresponds to PageSegMode enum in wrapper:
0 OSD only → PageSegMode.OsdOnly
1 Auto + OSD → PageSegMode.AutoOsd
2 Auto only, no OCR → PageSegMode.AutoOnly
3 Fully auto (default) → PageSegMode.Auto
4 Single column → PageSegMode.SingleColumn
5 Single block vertical → PageSegMode.SingleBlockVertText
6 Single block → PageSegMode.SingleBlock
7 Single line → PageSegMode.SingleLine
8 Single word → PageSegMode.SingleWord
9 Circle word → PageSegMode.CircleWord
10 Single char → PageSegMode.SingleChar
11 Sparse text → PageSegMode.SparseText
12 Sparse text + OSD → PageSegMode.SparseTextOsd
13 Raw line → PageSegMode.RawLine
Dictionary & character control
Disable dictionaries for non-dictionary text: load_system_dawg=0, load_freq_dawg=0
Character whitelist: tessedit_char_whitelist
User words: place eng.user-words in tessdata, set user_words_suffix=user-words
User patterns: place eng.user-patterns in tessdata (see tessdoc/APIExample-user_patterns.md)
Language model penalties: language_model_penalty_non_dict_word (default 0.15), language_model_penalty_non_freq_dict_word (default 0.1)
Traineddata Files
Three variants available. The tessdata repo files contain both legacy + LSTM models. tessdata_fast/tessdata_best are LSTM-only.
Repo
Speed
Accuracy
Legacy OEM
Retrainable
tessdata
Fast+
Good
Yes (OEM 0)
No
tessdata_fast
Fastest
Fair
No
No
tessdata_best
Slowest
Best
No
Yes
eng.traineddata → English
osd.traineddata → orientation/script detection (always needed for OSD)
equ.traineddata → math/equation detection
Multi-language: eng+deu, hin+eng, or script-level script/Devanagari
Supported input formats (via Leptonica)
PNG, JPEG, TIFF, JPEG 2000, GIF, WebP, BMP, PNM.
Unsupported: PDF (use OCRmyPDF to convert first), HEIC, AVIF, animated WebP/GIF.