Files
XplorePlane/XP.ImageProcessing.Processors/定位识别/TemplateMatchAlignmentExtensions.cs
T
李伟 7447463c1a feat: ROI 对齐工具与 TM_Result 位姿扩展
- Core: Pose2D、Point2D、RoiAlignment、AlignmentRecipe(示教多边形→运行图刚体变换)

- Processors: TemplateMatchAlignmentExtensions.ToPose2D / 四角与中心一致性校验

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-15 14:31:48 +08:00

28 lines
919 B
C#

using XP.ImageProcessing.Core.Alignment;
namespace XP.ImageProcessing.Processors;
/// <summary>
/// 将 TemplateMatchLib 匹配结果转换为对齐工具使用的 <see cref="Pose2D"/>。
/// </summary>
public static class TemplateMatchAlignmentExtensions
{
public static Pose2D ToPose2D(this TM_Result result)
=> new(result.CenterX, result.CenterY, result.Angle);
/// <summary>四角质心是否与 Center 一致(容差默认 1 像素)。</summary>
public static bool IsCenterConsistentWithCorners(this TM_Result result, double tolerancePixels = 1.0)
=> RoiAlignment.IsMatchCenterConsistentWithCorners(
result.CenterX,
result.CenterY,
result.LtX,
result.LtY,
result.RtX,
result.RtY,
result.RbX,
result.RbY,
result.LbX,
result.LbY,
tolerancePixels);
}