検出器の詳細設定
experimental
このページで説明する設定は experimental です。今後のバージョンで仕様が変更される可能性があります。詳しくは Experimental 機能の概要を参照してください。
ModelSettings から、検出器(画像内の文字やバーコードの位置を見つけるモデル)の詳細な挙動を調整できます。
YotsukaD 検出モデルの信頼度の閾値
YotsukaDDetectorSettings の confidenceThreshold で、YotsukaD 検出モデルがバーコードとして検出する最低信頼度を指定します。YotsukaD 検出モデルは barcode_next で使用されています。
| 項目 | 既定値 | 説明 |
|---|---|---|
confidenceThreshold | 0.3 | 検出の信頼度の閾値(0.0〜1.0)。低くすると見つけられるバーコードが増えますが、誤検出も増えます。高くすると誤検出が減りますが、見逃しが増えます。 |
範囲外の値を指定すると、モデルのロード時にエラーになります。
- iOS (Swift)
- Android (Java)
var modelSettings = ModelSettings()
modelSettings.yotsukaDDetectorSettings = YotsukaDDetectorSettings(confidenceThreshold: 0.5)
let modelInfo = try await edgeOCR.useModel(model, settings: modelSettings)
ModelSettings modelSettings = new ModelSettings();
modelSettings.setYotsukaDDetectorSettings(new YotsukaDDetectorSettings(0.5f));
api.useModel(model, modelSettings, successCallback, errorCallback);
文字検出結果のポストプロセス
DBTextDetectorSettings の postProcessing で、文字検出モデルの出力に適用するポストプロセスを指定します。すべての OCR モデル(model-d320x320 など)の文字検出で使用されます。
| 値 | 説明 |
|---|---|
None(既定) | ポストプロセスを行いません。 |
OpeningClosing | 検出結果に対してモルフォロジー演算のオープニングとクロージングを行い、細かなノイズを除去して欠けを埋めます。 |
HorizontalMerger84 | 横方向に間の空いた文字をつなげて、1 つの文字列として検出します。文字間隔の広い文字列が途中で分割されて認識される場合に有効です。 |
HorizontalMerger84 を使うと、横に並んだ別々の文字列まで 1 つにつながる場合があります。実際の読み取り対象で確認したうえで使用してください。
以下は HorizontalMerger84 を指定する例です。
- iOS (Swift)
- Android (Java)
var modelSettings = ModelSettings()
// Swift ではすべての項目の指定が必要なため、postProcessing 以外は既定値を指定する
modelSettings.dbTextDetectorSettings = DBTextDetectorSettings(
binaryThreshold: 0.3,
widthFactor: 1.5,
heightFactor: 3.0,
postProcessing: .HorizontalMerger84)
let modelInfo = try await edgeOCR.useModel(model, settings: modelSettings)
ModelSettings modelSettings = new ModelSettings();
DBTextDetectorSettings db = modelSettings.getDBTextDetectorSettings();
db.setPostProcessing(DBPostProcessing.HorizontalMerger84);
modelSettings.setDBTextDetectorSettings(db);
api.useModel(model, modelSettings, successCallback, errorCallback);