using System; using System.Collections.Generic; namespace VisionCommon { public class Fixture { /// /// FixtureResult를 기준으로 이동시킨 ROI를 리턴한다. /// /// 패턴 타입 /// 원본 ROI /// 기준 패턴 결과 /// 각도 반전 플래그. MIL과 Cognex의 각도 방향은 반대. Default : "true" /// 회전 및 이동이 반영된 ROI 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) { throw new NotImplementedException(); } } }