#pragma once // // Templates.h - 「目的から選ぶ」ための完成済みレシピ。 // ユーザーは目的を選ぶだけ。あとは右パネルのスライダーで微調整できる。 // #include "Recipe.h" #include "StepCatalog.h" #include namespace core { struct RecipeTemplate { CString name; // 目的名 CString desc; // 説明 Recipe recipe; // 中身 }; inline Step Mk(StepKind k) { return MakeStep(k); } inline std::vector AllTemplates() { std::vector v; // 1) キズ・汚れを見つける { RecipeTemplate t; t.name = L"キズ・汚れを見つける"; t.desc = L"白黒化→ノイズ除去→自動二値化し、キズ(白い塊)の数が0個なら合格。"; t.recipe.steps.push_back(Mk(StepKind::Grayscale)); t.recipe.steps.push_back(Mk(StepKind::Median)); t.recipe.steps.push_back(Mk(StepKind::Otsu)); { Step s = Mk(StepKind::InspectBlobCount); s.SetParam(L"thresh", 128); s.SetParam(L"invert", 1); // 暗い欠陥を数える s.SetParam(L"min", 0); s.SetParam(L"max", 0); t.recipe.steps.push_back(s); } v.push_back(t); } // 2) 欠け・穴を数える { RecipeTemplate t; t.name = L"欠け・穴を数える"; t.desc = L"白黒化→自動二値化し、穴(塊)の数が想定範囲(既定1〜4個)なら合格。"; t.recipe.steps.push_back(Mk(StepKind::Grayscale)); t.recipe.steps.push_back(Mk(StepKind::Otsu)); { Step s = Mk(StepKind::InspectBlobCount); s.SetParam(L"thresh", 128); s.SetParam(L"invert", 1); // 暗い穴を数える s.SetParam(L"min", 1); s.SetParam(L"max", 4); t.recipe.steps.push_back(s); } v.push_back(t); } // 3) 明るさ(ムラ)を確認する { RecipeTemplate t; t.name = L"明るさを確認する"; t.desc = L"白黒化し、全体の平均の明るさが範囲(既定80〜180)なら合格。"; t.recipe.steps.push_back(Mk(StepKind::Grayscale)); { Step s = Mk(StepKind::InspectBrightness); s.SetParam(L"min", 80); s.SetParam(L"max", 180); t.recipe.steps.push_back(s); } v.push_back(t); } // 4) 文字・印字の有無を見る { RecipeTemplate t; t.name = L"文字・印字の有無を見る"; t.desc = L"白黒化→二値化し、インク(白い部分)の割合が一定以上あれば合格=印字あり。"; t.recipe.steps.push_back(Mk(StepKind::Grayscale)); { Step s = Mk(StepKind::Binarize); s.SetParam(L"lo", 128); s.SetParam(L"hi", 255); s.SetParam(L"invert", 1); t.recipe.steps.push_back(s); } { Step s = Mk(StepKind::InspectWhiteRatio); s.SetParam(L"thresh", 128); s.SetParam(L"min", 2); s.SetParam(L"max", 100); t.recipe.steps.push_back(s); } v.push_back(t); } return v; } } // namespace core