using Cognex.VisionPro.CalibFix;
using MathNet.Numerics.LinearAlgebra;
using Newtonsoft.Json;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Media3D;
using TeamAAS_VP.Enums;
using TeamAAS_VP.Models.Robot;
namespace TeamAAS_VP.Models.Calibration
{
[JsonObject(MemberSerialization.OptOut)]
public class CalibrationInfo : 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;
///
/// 机器人
///
public Guid RobotId
{
get { return _RobotId; }
set { SetProperty(ref _RobotId, value); }
}
private Guid _FeederId;
///
/// Feeder
///
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 int _CameraMotionModuleIndex;
///
/// 相机运动模块的编号
///
public int CameraMotionModuleIndex
{
get { return _CameraMotionModuleIndex; }
set { SetProperty(ref _CameraMotionModuleIndex, value); }
}
private PickInfo _Pick;
///
/// 取料方式
///
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;
///
/// 工具坐标
///
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 _FixedDownCameraNoReturnToHome;
///
/// 固定向下相机时是否不需要每次回到待机点
///
public bool FixedDownCameraNoReturnToHome
{
get { return _FixedDownCameraNoReturnToHome; }
set { SetProperty(ref _FixedDownCameraNoReturnToHome, 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 RPoint _PutPoint;
///
/// 移动相机时。通过下相机校准P0的标定快放置位置
///
public RPoint PutPoint
{
get { return _PutPoint; }
set { SetProperty(ref _PutPoint, value); }
}
//
private RPoint _DownCameraPoint;
///
/// 移动相机时。通过下相机校准P0的下相机拍照位置
///
public RPoint DownCameraPoint
{
get { return _DownCameraPoint; }
set { SetProperty(ref _DownCameraPoint, value); }
}
private RPoint _IndependentDownCameraMotionModulePoint;
///
/// 独立的移动固定向下相机的模组位置
///
public RPoint IndependentDownCameraMotionModulePoint
{
get { return _IndependentDownCameraMotionModulePoint; }
set { SetProperty(ref _IndependentDownCameraMotionModulePoint, value); }
}
private double _IndependentDownCameraMotionModuleMoveX;
///
/// 独立模组X轴移动的距离
///
public double IndependentDownCameraMotionModuleMoveX
{
get { return _IndependentDownCameraMotionModuleMoveX; }
set { SetProperty(ref _IndependentDownCameraMotionModuleMoveX, value); }
}
private double[,] _IndependentDownCameraMotionModuleRotationMatrix;
///
/// 独立移动模组的旋转矩阵
///
public double[,] IndependentDownCameraMotionModuleRotationMatrix
{
get { return _IndependentDownCameraMotionModuleRotationMatrix; }
set { SetProperty(ref _IndependentDownCameraMotionModuleRotationMatrix, value); }
}
private double[,] _IndependentDownCameraMotionModuleTranslationMatrix;
///
/// 独立移动模组的平移矩阵
///
public double[,] IndependentDownCameraMotionModuleTranslationMatrix
{
get { return _IndependentDownCameraMotionModuleTranslationMatrix; }
set { SetProperty(ref _IndependentDownCameraMotionModuleTranslationMatrix, 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 FixedUpCameraFindP0Info _FixedUpCameraFindP0Info;
///
/// 移动相机时,下相机校准P0
///
public FixedUpCameraFindP0Info FixedUpCameraFindP0Info
{
get { return _FixedUpCameraFindP0Info; }
set { SetProperty(ref _FixedUpCameraFindP0Info, 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); }
}
///
/// 流程
///
[JsonIgnore]
public Cognex.VisionPro.ToolBlock.CogToolBlock ToolBlock { get; set; }
[JsonIgnore]
public CogCalibCheckerboardTool CalibCheckerboardTool { get; set; }
public CalibrationInfo Clone()
{
try
{
return JsonConvert.DeserializeObject(JsonConvert.SerializeObject(this));
}
catch (Exception)
{
return this;
}
}
}
}