namespace XP.ImageProcessing.Core.Alignment;
///
/// 示教阶段保存的对齐配方:基准位姿 + 示教图像素坐标下的检测 ROI。
///
public sealed class AlignmentRecipe
{
/// 示教图上的基准位姿(建议示教图自匹配得到,或与模板 ROI 中心 + 角度 0 一致)。
public Pose2D ReferencePose { get; set; }
/// 示教图上的 ROI 多边形顶点(至少 3 点)。
public List RoiPoints { get; set; } = new();
/// 将示教 ROI 变换到运行图坐标。
public Point2D[] TransformRoi(Pose2D measuredPose)
=> RoiAlignment.TransformPolygon(RoiPoints, ReferencePose, measuredPose);
/// 变换为整型顶点,供检测算子注入。
public (int X, int Y)[] TransformRoiToInt(Pose2D measuredPose)
=> RoiAlignment.TransformPolygonToInt(RoiPoints, ReferencePose, measuredPose);
/// 从算子参数字典读取示教多边形并填充 。
public static AlignmentRecipe FromTeachParameters(
Pose2D referencePose,
IReadOnlyDictionary parameters)
{
var points = RoiAlignmentApplier.ReadTeachPolygon(parameters);
return new AlignmentRecipe
{
ReferencePose = referencePose,
RoiPoints = points.ToList()
};
}
}