using Newtonsoft.Json; using System; using System.Collections.ObjectModel; using System.Linq; using TeamAAS.Robot.Models; using TeamAAS.Robot.Models.Robot; using TeamAAS.Vision.Calibration.Enums; namespace TeamAAS.Vision.Calibration.Models { /// /// 一次标定的完整配置与结果。 /// 引擎无关:视觉工具以 (运行时句柄,不序列化) /// 与 (持久化引用,如 .vpp 路径)表示, /// 具体由当前视觉引擎(VisionPro/VM/Halcon)解释。 /// [JsonObject(MemberSerialization.OptOut)] public class CalibrationInfo : TeamAAS.BindableBase { private bool _IsCreate; /// 正在创建(尚未持久化)。 [JsonIgnore] public bool IsCreate { get { return _IsCreate; } set { SetProperty(ref _IsCreate, value); } } private Guid _Id; public Guid Id { get { return _Id; } set { SetProperty(ref _Id, value); } } private int _Index; /// 编号。 public int Index { get { return _Index; } set { SetProperty(ref _Index, value); } } private string _Name; /// 校准的名称。 public string Name { get { return _Name; } set { SetProperty(ref _Name, value); } } private DateTime _DateTime; public DateTime DateTime { get { return _DateTime; } set { SetProperty(ref _DateTime, value); } } private string _CameraName; /// 相机名称。 public string CameraName { get { return _CameraName; } set { SetProperty(ref _CameraName, value); } } private Guid _CameraID; /// 相机 ID。 public Guid CameraID { get { return _CameraID; } set { SetProperty(ref _CameraID, value); } } private Guid _RobotId; /// 机器人 ID。 public Guid RobotId { get { return _RobotId; } set { SetProperty(ref _RobotId, value); } } private Guid _FeederId; /// Feeder(喂料器/光源)ID。 public Guid FeederId { get { return _FeederId; } set { SetProperty(ref _FeederId, value); } } private CameraMount _CameraMount; /// 相机安装方式。 public CameraMount CameraMount { get { return _CameraMount; } set { SetProperty(ref _CameraMount, value); } } private PickInfo _Pick; /// 取料方式(吸取/夹取 + IO 点位)。 public PickInfo Pick { get { return _Pick; } set { SetProperty(ref _Pick, value); } } private int _Brightness; /// 光源亮度。 public int Brightness { get { return _Brightness; } set { SetProperty(ref _Brightness, value); } } private float _ExposureTime; /// 相机曝光时间。 public float ExposureTime { get { return _ExposureTime; } set { SetProperty(ref _ExposureTime, value); } } private float _Gain; /// 相机增益。 public float Gain { get { return _Gain; } set { SetProperty(ref _Gain, value); } } private CalibTechP0Mode _CalibTechP0Mode; /// 移动相机中心作为 P0 还是手动示教 P0。 public CalibTechP0Mode CalibTechP0Mode { get { return _CalibTechP0Mode; } set { SetProperty(ref _CalibTechP0Mode, value); } } private RPoint _CenterPoint; /// 中心点。 public RPoint CenterPoint { get { return _CenterPoint; } set { SetProperty(ref _CenterPoint, value); } } private RPoint _HomePoint; /// 待机点。 public RPoint HomePoint { get { return _HomePoint; } set { SetProperty(ref _HomePoint, value); } } private double _Width; /// 机器人移动的范围 X。 public double Width { get { return _Width; } set { SetProperty(ref _Width, value); } } private double _Height; /// 机器人移动的范围 Y。 public double Height { get { return _Height; } set { SetProperty(ref _Height, value); } } private double _Angle = 180; /// 机器人移动的范围 U(旋转标定用角度)。 public double Angle { get { return _Angle; } set { SetProperty(ref _Angle, value); } } private RobotTool _Tool; /// 工具坐标(TCP)。 public RobotTool Tool { get { return _Tool; } set { SetProperty(ref _Tool, value); } } private RobotArm _Arm; /// Arm。 public RobotArm Arm { get { return _Arm; } set { SetProperty(ref _Arm, value); } } private int _Speed; public int Speed { get { return _Speed; } set { SetProperty(ref _Speed, value); } } private int _Accel; public int Accel { get { return _Accel; } set { SetProperty(ref _Accel, value); } } private int _WaitPhoto; public int WaitPhoto { get { return _WaitPhoto; } set { SetProperty(ref _WaitPhoto, value); } } private int _WaitSuction; /// 吸真空延时。 public int WaitSuction { get { return _WaitSuction; } set { SetProperty(ref _WaitSuction, value); } } private int _WaitBlow; /// 破真空延时。 public int WaitBlow { get { return _WaitBlow; } set { SetProperty(ref _WaitBlow, value); } } private bool _Power; public bool Power { get { return _Power; } set { SetProperty(ref _Power, value); } } private bool _IsDistortionCorrection; /// 是否进行畸变校正。 public bool IsDistortionCorrection { get { return _IsDistortionCorrection; } set { SetProperty(ref _IsDistortionCorrection, value); } } private RPoint _MarkPoint; /// 特征点的坐标(移动相机模式下记录标定块绝对坐标)。 public RPoint MarkPoint { get { return _MarkPoint; } set { SetProperty(ref _MarkPoint, value); } } private ObservableCollection _CalibPoints; /// 9 点校准点(机器人坐标与像素坐标对应)。 public ObservableCollection CalibPoints { get { return _CalibPoints; } set { SetProperty(ref _CalibPoints, value); } } private double[,] _RobotCameraRotationMatrix; /// 机器人与相机之间的旋转矩阵。 public double[,] RobotCameraRotationMatrix { get { return _RobotCameraRotationMatrix; } set { SetProperty(ref _RobotCameraRotationMatrix, value); } } private double _PixelScaleX; /// 图像 X 方向像素与毫米缩放系数,mm/pixel。 public double PixelScaleX { get { return _PixelScaleX; } set { SetProperty(ref _PixelScaleX, value); } } private double _PixelScaleY; /// 图像 Y 方向像素与毫米缩放系数,mm/pixel。 public double PixelScaleY { get { return _PixelScaleY; } set { SetProperty(ref _PixelScaleY, value); } } private double[,] _AffineTransformationMaterial; /// 仿射变换 2*3 矩阵(像素 → 机器人)。 public double[,] AffineTransformationMaterial { get { return _AffineTransformationMaterial; } set { SetProperty(ref _AffineTransformationMaterial, value); } } private CalibrationResult _CalibrationResult; /// 校准结果。 public CalibrationResult CalibrationResult { get { return _CalibrationResult; } set { SetProperty(ref _CalibrationResult, value); } } private CalibrationTestResult _CalibrationTestResult; /// 校准验证结果。 public CalibrationTestResult CalibrationTestResult { get { return _CalibrationTestResult; } set { SetProperty(ref _CalibrationTestResult, value); } } private string _VisionToolRef; /// 视觉标定工具的持久化引用(如 .vpp 路径),随引擎解释。 public string VisionToolRef { get { return _VisionToolRef; } set { SetProperty(ref _VisionToolRef, value); } } /// 视觉标定工具的运行时句柄(引擎私有对象,不序列化)。 [JsonIgnore] public object VisionTool { get; set; } /// 畸变校正工具的运行时句柄(引擎私有对象,不序列化)。 [JsonIgnore] public object DistortionTool { get; set; } public CalibrationInfo Clone() { return new CalibrationInfo { Id = this.Id, Index = this.Index, Name = this.Name, DateTime = this.DateTime, CameraName = this.CameraName, CameraID = this.CameraID, RobotId = this.RobotId, FeederId = this.FeederId, CameraMount = this.CameraMount, Pick = this.Pick?.Clone(), Brightness = this.Brightness, ExposureTime = this.ExposureTime, Gain = this.Gain, CalibTechP0Mode = this.CalibTechP0Mode, CenterPoint = this.CenterPoint?.Clone(), HomePoint = this.HomePoint?.Clone(), Width = this.Width, Height = this.Height, Angle = this.Angle, Tool = this.Tool?.Copy(), Arm = this.Arm, Speed = this.Speed, Accel = this.Accel, WaitPhoto = this.WaitPhoto, WaitSuction = this.WaitSuction, WaitBlow = this.WaitBlow, Power = this.Power, IsDistortionCorrection = this.IsDistortionCorrection, MarkPoint = this.MarkPoint?.Clone(), CalibPoints = new ObservableCollection((this.CalibPoints ?? new ObservableCollection()).Select(p => p.Clone())), RobotCameraRotationMatrix = (double[,])this.RobotCameraRotationMatrix?.Clone(), PixelScaleX = this.PixelScaleX, PixelScaleY = this.PixelScaleY, AffineTransformationMaterial = (double[,])this.AffineTransformationMaterial?.Clone(), VisionToolRef = this.VisionToolRef, }; } } }