CalibrationInfo.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. using Cognex.VisionPro.CalibFix;
  2. using MathNet.Numerics.LinearAlgebra;
  3. using Newtonsoft.Json;
  4. using Prism.Mvvm;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Collections.ObjectModel;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Media.Media3D;
  12. using TeamAAS_VP.Enums;
  13. using TeamAAS_VP.Models.Robot;
  14. namespace TeamAAS_VP.Models.Calibration
  15. {
  16. [JsonObject(MemberSerialization.OptOut)]
  17. public class CalibrationInfo : BindableBase
  18. {
  19. private bool _IsCreate;
  20. /// <summary>
  21. /// 正在创建
  22. /// </summary>
  23. [JsonIgnore]
  24. public bool IsCreate
  25. {
  26. get { return _IsCreate; }
  27. set { SetProperty(ref _IsCreate, value); }
  28. }
  29. private Guid _Id;
  30. public Guid Id
  31. {
  32. get { return _Id; }
  33. set { SetProperty(ref _Id, value); }
  34. }
  35. private int _Index;
  36. /// <summary>
  37. /// 编号
  38. /// </summary>
  39. public int Index
  40. {
  41. get { return _Index; }
  42. set { SetProperty(ref _Index, value); }
  43. }
  44. private string _Name;
  45. /// <summary>
  46. /// 校准的名称
  47. /// </summary>
  48. public string Name
  49. {
  50. get { return _Name; }
  51. set { SetProperty(ref _Name, value); }
  52. }
  53. private DateTime _DateTime;
  54. public DateTime DateTime
  55. {
  56. get { return _DateTime; }
  57. set { SetProperty(ref _DateTime, value); }
  58. }
  59. private string _CameraName;
  60. /// <summary>
  61. /// 相机名称
  62. /// </summary>
  63. public string CameraName
  64. {
  65. get { return _CameraName; }
  66. set { SetProperty(ref _CameraName, value); }
  67. }
  68. private Guid _CameraID;
  69. /// <summary>
  70. /// 相机ID
  71. /// </summary>
  72. public Guid CameraID
  73. {
  74. get { return _CameraID; }
  75. set { SetProperty(ref _CameraID, value); }
  76. }
  77. private Guid _RobotId;
  78. /// <summary>
  79. /// 机器人
  80. /// </summary>
  81. public Guid RobotId
  82. {
  83. get { return _RobotId; }
  84. set { SetProperty(ref _RobotId, value); }
  85. }
  86. private Guid _FeederId;
  87. /// <summary>
  88. /// Feeder
  89. /// </summary>
  90. public Guid FeederId
  91. {
  92. get { return _FeederId; }
  93. set { SetProperty(ref _FeederId, value); }
  94. }
  95. private CameraMount _CameraMount;
  96. /// <summary>
  97. /// 相机安装方式
  98. /// </summary>
  99. public CameraMount CameraMount
  100. {
  101. get { return _CameraMount; }
  102. set { SetProperty(ref _CameraMount, value); }
  103. }
  104. private int _CameraMotionModuleIndex;
  105. /// <summary>
  106. /// 相机运动模块的编号
  107. /// </summary>
  108. public int CameraMotionModuleIndex
  109. {
  110. get { return _CameraMotionModuleIndex; }
  111. set { SetProperty(ref _CameraMotionModuleIndex, value); }
  112. }
  113. private PickInfo _Pick;
  114. /// <summary>
  115. /// 取料方式
  116. /// </summary>
  117. public PickInfo Pick
  118. {
  119. get { return _Pick; }
  120. set { SetProperty(ref _Pick, value); }
  121. }
  122. private int _Brightness;
  123. /// <summary>
  124. /// 光源亮度
  125. /// </summary>
  126. public int Brightness
  127. {
  128. get { return _Brightness; }
  129. set { SetProperty(ref _Brightness, value); }
  130. }
  131. private float _ExposureTime;
  132. /// <summary>
  133. /// 相机曝光时间
  134. /// </summary>
  135. public float ExposureTime
  136. {
  137. get { return _ExposureTime; }
  138. set { SetProperty(ref _ExposureTime, value); }
  139. }
  140. private float _Gain;
  141. /// <summary>
  142. /// 相机增益
  143. /// </summary>
  144. public float Gain
  145. {
  146. get { return _Gain; }
  147. set { SetProperty(ref _Gain, value); }
  148. }
  149. private CalibTechP0Mode _CalibTechP0Mode;
  150. /// <summary>
  151. /// 移动相机中心作为P0还是手动示教P0
  152. /// </summary>
  153. public CalibTechP0Mode CalibTechP0Mode
  154. {
  155. get { return _CalibTechP0Mode; }
  156. set { SetProperty(ref _CalibTechP0Mode, value); }
  157. }
  158. private RPoint _CenterPoint;
  159. /// <summary>
  160. /// 中心点
  161. /// </summary>
  162. public RPoint CenterPoint
  163. {
  164. get { return _CenterPoint; }
  165. set { SetProperty(ref _CenterPoint, value); }
  166. }
  167. private RPoint _HomePoint;
  168. /// <summary>
  169. /// 待机点
  170. /// </summary>
  171. public RPoint HomePoint
  172. {
  173. get { return _HomePoint; }
  174. set { SetProperty(ref _HomePoint, value); }
  175. }
  176. private double _Width;
  177. /// <summary>
  178. /// 机器人移动的范围X
  179. /// </summary>
  180. public double Width
  181. {
  182. get { return _Width; }
  183. set { SetProperty(ref _Width, value); }
  184. }
  185. private double _Height;
  186. /// <summary>
  187. /// 机器人移动的范围Y
  188. /// </summary>
  189. public double Height
  190. {
  191. get { return _Height; }
  192. set { SetProperty(ref _Height, value); }
  193. }
  194. private double _Angle = 180;
  195. /// <summary>
  196. /// 机器人移动的范围U
  197. /// </summary>
  198. public double Angle
  199. {
  200. get { return _Angle; }
  201. set { SetProperty(ref _Angle, value); }
  202. }
  203. private RobotTool _Tool;
  204. /// <summary>
  205. /// 工具坐标
  206. /// </summary>
  207. public RobotTool Tool
  208. {
  209. get { return _Tool; }
  210. set { SetProperty(ref _Tool, value); }
  211. }
  212. private RobotArm _Arm;
  213. /// <summary>
  214. /// Arm
  215. /// </summary>
  216. public RobotArm Arm
  217. {
  218. get { return _Arm; }
  219. set { SetProperty(ref _Arm, value); }
  220. }
  221. private int _Speed;
  222. public int Speed
  223. {
  224. get { return _Speed; }
  225. set { SetProperty(ref _Speed, value); }
  226. }
  227. private int _Accel;
  228. public int Accel
  229. {
  230. get { return _Accel; }
  231. set { SetProperty(ref _Accel, value); }
  232. }
  233. private int _WaitPhoto;
  234. public int WaitPhoto
  235. {
  236. get { return _WaitPhoto; }
  237. set { SetProperty(ref _WaitPhoto, value); }
  238. }
  239. private int _WaitSuction;
  240. /// <summary>
  241. /// 吸真空延时
  242. /// </summary>
  243. public int WaitSuction
  244. {
  245. get { return _WaitSuction; }
  246. set { SetProperty(ref _WaitSuction, value); }
  247. }
  248. private int _WaitBlow;
  249. /// <summary>
  250. /// 破真空延时
  251. /// </summary>
  252. public int WaitBlow
  253. {
  254. get { return _WaitBlow; }
  255. set { SetProperty(ref _WaitBlow, value); }
  256. }
  257. private bool _Power;
  258. public bool Power
  259. {
  260. get { return _Power; }
  261. set { SetProperty(ref _Power, value); }
  262. }
  263. private bool _FixedDownCameraNoReturnToHome;
  264. /// <summary>
  265. /// 固定向下相机时是否不需要每次回到待机点
  266. /// </summary>
  267. public bool FixedDownCameraNoReturnToHome
  268. {
  269. get { return _FixedDownCameraNoReturnToHome; }
  270. set { SetProperty(ref _FixedDownCameraNoReturnToHome, value); }
  271. }
  272. private bool _IsDistortionCorrection;
  273. /// <summary>
  274. /// 是否进行畸变校正
  275. /// </summary>
  276. public bool IsDistortionCorrection
  277. {
  278. get { return _IsDistortionCorrection; }
  279. set { SetProperty(ref _IsDistortionCorrection, value); }
  280. }
  281. private RPoint _MarkPoint;
  282. /// <summary>
  283. /// 特征点的坐标
  284. /// </summary>
  285. public RPoint MarkPoint
  286. {
  287. get { return _MarkPoint; }
  288. set { SetProperty(ref _MarkPoint, value); }
  289. }
  290. private RPoint _PutPoint;
  291. /// <summary>
  292. /// 移动相机时。通过下相机校准P0的标定快放置位置
  293. /// </summary>
  294. public RPoint PutPoint
  295. {
  296. get { return _PutPoint; }
  297. set { SetProperty(ref _PutPoint, value); }
  298. }
  299. //
  300. private RPoint _DownCameraPoint;
  301. /// <summary>
  302. /// 移动相机时。通过下相机校准P0的下相机拍照位置
  303. /// </summary>
  304. public RPoint DownCameraPoint
  305. {
  306. get { return _DownCameraPoint; }
  307. set { SetProperty(ref _DownCameraPoint, value); }
  308. }
  309. private RPoint _IndependentDownCameraMotionModulePoint;
  310. /// <summary>
  311. /// 独立的移动固定向下相机的模组位置
  312. /// </summary>
  313. public RPoint IndependentDownCameraMotionModulePoint
  314. {
  315. get { return _IndependentDownCameraMotionModulePoint; }
  316. set { SetProperty(ref _IndependentDownCameraMotionModulePoint, value); }
  317. }
  318. private double _IndependentDownCameraMotionModuleMoveX;
  319. /// <summary>
  320. /// 独立模组X轴移动的距离
  321. /// </summary>
  322. public double IndependentDownCameraMotionModuleMoveX
  323. {
  324. get { return _IndependentDownCameraMotionModuleMoveX; }
  325. set { SetProperty(ref _IndependentDownCameraMotionModuleMoveX, value); }
  326. }
  327. private double[,] _IndependentDownCameraMotionModuleRotationMatrix;
  328. /// <summary>
  329. /// 独立移动模组的旋转矩阵
  330. /// </summary>
  331. public double[,] IndependentDownCameraMotionModuleRotationMatrix
  332. {
  333. get { return _IndependentDownCameraMotionModuleRotationMatrix; }
  334. set { SetProperty(ref _IndependentDownCameraMotionModuleRotationMatrix, value); }
  335. }
  336. private double[,] _IndependentDownCameraMotionModuleTranslationMatrix;
  337. /// <summary>
  338. /// 独立移动模组的平移矩阵
  339. /// </summary>
  340. public double[,] IndependentDownCameraMotionModuleTranslationMatrix
  341. {
  342. get { return _IndependentDownCameraMotionModuleTranslationMatrix; }
  343. set { SetProperty(ref _IndependentDownCameraMotionModuleTranslationMatrix, value); }
  344. }
  345. private ObservableCollection<RobotPixelPoint> _CalibPoints;
  346. /// <summary>
  347. /// 9点校准点
  348. /// </summary>
  349. public ObservableCollection<RobotPixelPoint> CalibPoints
  350. {
  351. get { return _CalibPoints; }
  352. set { SetProperty(ref _CalibPoints, value); }
  353. }
  354. private double[,] _RobotCameraRotationMatrix;
  355. /// <summary>
  356. /// 机器人与相机之间的旋转矩阵
  357. /// </summary>
  358. public double[,] RobotCameraRotationMatrix
  359. {
  360. get { return _RobotCameraRotationMatrix; }
  361. set { SetProperty(ref _RobotCameraRotationMatrix, value); }
  362. }
  363. private double _PixelScaleX;
  364. /// <summary>
  365. /// 图像X方向像素与毫米缩放系数,mm/pixel
  366. /// </summary>
  367. public double PixelScaleX
  368. {
  369. get { return _PixelScaleX; }
  370. set { SetProperty(ref _PixelScaleX, value); }
  371. }
  372. private double _PixelScaleY;
  373. /// <summary>
  374. /// 图像Y方向像素与毫米缩放系数,mm/pixel
  375. /// </summary>
  376. public double PixelScaleY
  377. {
  378. get { return _PixelScaleY; }
  379. set { SetProperty(ref _PixelScaleY, value); }
  380. }
  381. private double[,] _AffineTransformationMaterial;
  382. /// <summary>
  383. /// 仿射变换2*3矩阵
  384. /// </summary>
  385. public double[,] AffineTransformationMaterial
  386. {
  387. get { return _AffineTransformationMaterial; }
  388. set { SetProperty(ref _AffineTransformationMaterial, value); }
  389. }
  390. private FixedUpCameraFindP0Info _FixedUpCameraFindP0Info;
  391. /// <summary>
  392. /// 移动相机时,下相机校准P0
  393. /// </summary>
  394. public FixedUpCameraFindP0Info FixedUpCameraFindP0Info
  395. {
  396. get { return _FixedUpCameraFindP0Info; }
  397. set { SetProperty(ref _FixedUpCameraFindP0Info, value); }
  398. }
  399. private CalibrationResult _CalibrationResult;
  400. /// <summary>
  401. /// 校准结果
  402. /// </summary>
  403. public CalibrationResult CalibrationResult
  404. {
  405. get { return _CalibrationResult; }
  406. set { SetProperty(ref _CalibrationResult, value); }
  407. }
  408. private CalibrationTestResult _CalibrationTestResult;
  409. public CalibrationTestResult CalibrationTestResult
  410. {
  411. get { return _CalibrationTestResult; }
  412. set { SetProperty(ref _CalibrationTestResult, value); }
  413. }
  414. /// <summary>
  415. /// 流程
  416. /// </summary>
  417. [JsonIgnore]
  418. public Cognex.VisionPro.ToolBlock.CogToolBlock ToolBlock { get; set; }
  419. [JsonIgnore]
  420. public CogCalibCheckerboardTool CalibCheckerboardTool { get; set; }
  421. public CalibrationInfo Clone()
  422. {
  423. try
  424. {
  425. return JsonConvert.DeserializeObject<CalibrationInfo>(JsonConvert.SerializeObject(this));
  426. }
  427. catch (Exception)
  428. {
  429. return this;
  430. }
  431. }
  432. }
  433. }