7447463c1a
- Core: Pose2D、Point2D、RoiAlignment、AlignmentRecipe(示教多边形→运行图刚体变换) - Processors: TemplateMatchAlignmentExtensions.ToPose2D / 四角与中心一致性校验 Co-authored-by: Cursor <cursoragent@cursor.com>
19 lines
932 B
C#
19 lines
932 B
C#
namespace XP.ImageProcessing.Core.Alignment;
|
|
|
|
/// <summary>
|
|
/// 图像平面上的刚体位姿:绕 <see cref="X"/>/<see cref="Y"/> 旋转 <see cref="AngleDegrees"/>(度)。
|
|
/// 与 TemplateMatchLib 的 CenterX/CenterY/Angle 约定一致。
|
|
/// </summary>
|
|
public readonly record struct Pose2D(double X, double Y, double AngleDegrees)
|
|
{
|
|
/// <summary>示教/标准姿态(角度 0,中心由调用方指定)。</summary>
|
|
public static Pose2D IdentityAt(double x, double y) => new(x, y, 0);
|
|
|
|
/// <summary>
|
|
/// 由模板学习 ROI 矩形估计示教位姿中心(pattern 几何中心),角度默认 0。
|
|
/// 更稳妥的做法是在示教图上自匹配得到 <see cref="Pose2D"/>。
|
|
/// </summary>
|
|
public static Pose2D FromTemplateRoiCenter(int roiX, int roiY, int roiWidth, int roiHeight, double angleDegrees = 0)
|
|
=> new(roiX + roiWidth * 0.5, roiY + roiHeight * 0.5, angleDegrees);
|
|
}
|