2026-06-05 13:44:39 +09:00

54 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
namespace VisionCommon {
public class Fixture {
/// <summary>
/// FixtureResult를 기준으로 이동시킨 ROI를 리턴한다.
/// </summary>
/// <param name="patternType">패턴 타입</param>
/// <param name="roi">원본 ROI</param>
/// <param name="fixtureResult">기준 패턴 결과</param>
/// <param name="isCounerClockwise">각도 반전 플래그. MIL과 Cognex의 각도 방향은 반대. Default : "true"</param>
/// <returns>회전 및 이동이 반영된 ROI</returns>
public static ROI GetFixtureROI(ePatternType patternType, ROI roi, FixtureResult fixtureResult, bool isCounerClockwise = true) {
// 1. Traslation
var transCenter = roi.Center + fixtureResult.Offset as ImagePoint;
// 2. Rotation of translated center with pattern origin
Angle angle;
if (isCounerClockwise) {
angle = -fixtureResult.Rotation; // MIL의 경우 angle 반전O (Default)
}
else {
angle = fixtureResult.Rotation; // Cognex의 경우 angle 반전X
}
var transRotatedCenter = MathUtil.Rotate(
transCenter, angle, fixtureResult.Origin) as ImagePoint;
// 3. Rotation of ROI itself with ROI center
var roiRotation = Angle.CreateWithDegree(0);
if (IsRotatableROI(patternType)) {
roiRotation = roi.Angle + fixtureResult.Rotation;
}
return new ROI(
transRotatedCenter,
roi.Width,
roi.Height,
roiRotation
);
}
public static bool IsRotatableROI(ePatternType patternType) {
return (patternType == ePatternType.LineFinder ||
patternType == ePatternType.EdgeFinder ||
patternType == ePatternType.Caliper);
}
public static ROI GetFixtureROI(ROI roi, List<FixtureResult> fixtureResult) {
throw new NotImplementedException();
}
}
}