ocr_train — SYMBOL ocr op

• Data kinds: कोई नहीं → table (केवल arguments से तय होने वाला op — यह कोई image या data input नहीं लेता)

• Call: import fullseye as fs; fs.ledger.ocr_train(font='dot5x7', char_height_px=(16, 20, 26, 34), variants=None, seed=0, neighbour='random') -> 'dict' (implementation को सीधे call करना हो तो import ocrclassic; ocrclassic.ocr_train(font='dot5x7', char_height_px=(16, 20, 26, 34), variants=None, seed=0, neighbour='random') -> 'dict', registry से लेना हो तो opssymbol.get("ocr_train"))

• GPU: नहीं (केवल CPU reference implementation)

उपयोग

font को nuisance variations के साथ render करके templates (features + labels) और rejection thresholds इकट्ठा करता है (table)।

> नीचे का विस्तृत विवरण मूल text में है — सारांश और headings का अनुवाद हो चुका है।

Render every character under a small deterministic set of nuisance variations and collect feature templates for k-NN.

各試料は「乱数(seed 固定)で選んだ隣字 + 字 + 隣字」の 3 字行として描き、撹乱(字高・にじみ・ぼけ・小数ずれ)をかけてから、読み取りと同じ規則で中央の字を切る: 字間の中点(真値)に最も近い列射影の極小を切れ目とし(読みの切れ目候補と同じ規則)、その間の字の画素(ink >= 0.5)の外接箱から、重心中心・送り幅の窓で特徴量を取る。隣字を固定(例 "H")にすると、読みの場で隣に来る字のにじみが学習に無く、ぼけ 0.1h で正解率が 2 割落ちた(実測)ので乱数にしている。切れなかった試料(字の画素が無い)は真値の箱で代替し、件数を n_fallback に残す。

Each sample is a 3-glyph line (seeded random neighbours + glyph + neighbour); the middle glyph is cut with the same rule as reading (profile minima nearest to the true gap midpoints) and featurised with the centroid-centred pitch-wide window. A fixed neighbour lost ~20 % accuracy at blur 0.1 h (measured), hence random neighbours.

Parameters

font : 書体名か書体辞書。

char_height_px : 字高の組(各 8..256)。既定 (16, 20, 26, 34)。

variants : {"ink_gain": tuple, "blur": tuple (σ / 字高), "subpixel": bool, "noise": float}。

None で既定(にじみ 3 x ぼけ 8 [0..0.14h, 0.02h 刻み] x 字高 4 = 1 字 96 試料、

40 字で 3840 試料)。

seed : 小数ずらし・隣字・雑音の乱数種(決定的)。

neighbour : "random"(既定)か字種内の 1 字。

Returns

dict

features (n, 88), labels (n,) str, weights (88,) 対角マハラノビスの重み,

blur (n,) 各試料のぼけ, blur_levels, blur_step, charset, font,

font_kind, k (=1), reject_distance(全体の値、帯を指定しない照合用),

reject_distance_by_class(字ごと), min_margin_ratio, reject_stats

(within_nn_p99, factor, between_nn_min, between_nn_p01), n_fallback,

heights。

棄却距離の導き方 / reject_distance derivation

各試料について「同クラス・ぼけ帯内(±1 格子点)の最近傍の他の試料までの重みつき距離」を

求め、字ごとにその 99 パーセンタイル x REJECT_FACTOR を棄却距離とする。

学習分布だけで決まる(係数の選び方は REJECT_FACTOR の注記を参照)。

Per class: REJECT_FACTOR x P99 of the within-class, within-band nearest-other-sample

weighted distance. Derived from the training distribution only.

उपयोग की विस्तृत guide

• symbol_reading family guide

संदर्भ (sample data, साहित्य)

• Sample data catalog (DL URL / license) — 2-D के लिए skimage.data (BSD/public) + synthetic, 3-D के लिए real data sources (Stanford/PDS आदि) के DL URL।

• Operators का स्रोत और संदर्भ — इस op family के मूल research/methods के स्रोत।

• Algorithm का मानक स्रोत (लेखक, वर्ष) और उपयोग ऊपर की family usage guide में दिए गए हैं।

चलाए जा सकने वाले उदाहरण (verified samples जो सच में यह op call करते हैं)

• poc_symbol_lot_ocr — py -3.11 examples/poc_symbol_lot_ocr.py

वे अगले ops जिनसे type जुड़ता है (table को input के रूप में लेते हैं)

render_symbol · symbol_read_trials · symbol_read_pod · ocr_classify · ocr_read_line · ocr_read_trials

इसी category के (ocr)

ocr_font · ocr_render_text · ocr_segment_line · ocr_features · ocr_classify · ocr_read_line · ocr_score · ocr_read_trials


*Provenance: ocrclassic.py — SYMBOL operator registry. यह per-op note tools/opdocs.py md से अपने-आप generate होता है (हाथ से edit न करें)।*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.