63 lines
2.3 KiB
C#
63 lines
2.3 KiB
C#
/*
|
|
* Copyright (c) 2025 LG Electronics Inc.
|
|
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
|
|
*/
|
|
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
|
|
Angle roiRotation;
|
|
if (fixtureResult.Rotation.Degree == 0) {
|
|
roiRotation = Angle.CreateWithDegree(0);
|
|
}
|
|
else {
|
|
roiRotation = roi.Angle + fixtureResult.Rotation;
|
|
}
|
|
|
|
return new ROI(
|
|
transRotatedCenter,
|
|
roi.Width,
|
|
roi.Height,
|
|
roiRotation
|
|
);
|
|
}
|
|
|
|
[Obsolete]
|
|
public static bool IsRotatableROI(ePatternType patternType) {
|
|
return (patternType == ePatternType.LineFinder ||
|
|
patternType == ePatternType.EdgeFinder ||
|
|
patternType == ePatternType.Caliper);
|
|
}
|
|
|
|
[Obsolete]
|
|
public static ROI GetFixtureROI(ROI roi, List<FixtureResult> fixtureResult) {
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|