2026-01-26 14:51:28 +09:00

61 lines
2.5 KiB
C#

/*
* Copyright (c) 2025 LG Electronics Inc.
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
*/
using Aurora.Api.DataType;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using VisionCommon;
namespace VisionCalibrator {
/// <summary>
/// MIL or Cognex 상호참조 해결을 위한 클래스
/// </summary>
public class CalManager : ICalManager {
/// <summary>
/// 켈리브레이터를 Get한다.
/// </summary>
/// <param name="fovInfo">FovInfo</param>
/// <returns>Calibrator</returns>
public object GetCalibrator(FovInfo fovInfo) {
return CalibratorManager.GetCalibrator(fovInfo);
}
/// <summary>
/// 이미지 좌표를 자재 좌표계로 변환한다
/// </summary>
/// <param name="fovInfo">FOV 정보</param>
/// <param name="imagePoint">변환할 이미지 좌표</param>
/// <param name="imageSize">변환할 이미지의 크기</param>
/// <returns>자재 좌표</returns>
public StaticPoint TransformToCalibratedSpace(FovInfo fovInfo, ImagePoint imagePoint, ImageSize imageSize) {
var fovRecipe = VisionRecipeManager.GetFovRecipe(fovInfo);
var fovCenter = fovRecipe.CalFovRecipe.FovCenter;
var calibrator = GetCalibrator(fovInfo) as Calibrator;
return calibrator.TransformToCalibratedSpace(fovCenter, imagePoint, imageSize.Width, imageSize.Height);
}
/// <summary>
/// 자재 좌표를 이미지 좌표계로 변환한다
/// </summary>
/// <param name="fovInfo">FOV 정보</param>
/// <param name="staticPoint">변환할 자재 좌표</param>
/// <param name="imageSize">변환할 이미지의 크기</param>
/// <returns>이미지 좌표</returns>
public ImagePoint TransformToImagePoint(FovInfo fovInfo, StaticPoint staticPoint, ImageSize imageSize) {
var fovRecipe = VisionRecipeManager.GetFovRecipe(fovInfo);
var fovCenter = fovRecipe.CalFovRecipe.FovCenter;
var calibrator = GetCalibrator(fovInfo) as Calibrator;
return calibrator.InverseTransformToCalibratedSpace(
fovRecipe.CalFovRecipe.FovCenter,
staticPoint,
imageSize.Width,
imageSize.Height,
fovRecipe.CalFovRecipe.ErrRotationX,
fovRecipe.CalFovRecipe.PixelSize
);
}
}
}