using Aurora.Api.DataType; using System.Collections.Generic; using System.Diagnostics; using System.Windows; using VisionCommon; namespace VisionCalibrator { /// /// MIL or Cognex 상호참조 해결을 위한 클래스 /// public class CalManager : ICalManager { /// /// 켈리브레이터를 Get한다. /// /// FovInfo /// Calibrator public object GetCalibrator(FovInfo fovInfo) { return CalibratorManager.GetCalibrator(fovInfo); } /// /// 이미지 좌표를 자재 좌표계로 변환한다 /// /// FOV 정보 /// 변환할 이미지 좌표 /// 변환할 이미지의 크기 /// 자재 좌표 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); } /// /// 자재 좌표를 이미지 좌표계로 변환한다 /// /// FOV 정보 /// 변환할 자재 좌표 /// 변환할 이미지의 크기 /// 이미지 좌표 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 ); } } }