VisionToolList.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. using CaliperTool;
  2. using CommonMethods;
  3. using EyeHandCalibTool;
  4. using FindLineTool;
  5. using HalconTool;
  6. using HDevEngineTool;
  7. using PMAlignTool;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. namespace VisionJobFactory
  14. {
  15. [Serializable]
  16. [VisionToolAttribute(ToolType.HalconTool)]
  17. public class HalconToolInterface : IToolInfo
  18. {
  19. // 必添加输出项
  20. ToolIO outputImage = new ToolIO("OutputImage", null, DataType.Image);
  21. /// <summary>
  22. /// 获取工具的所有信息
  23. /// </summary>
  24. /// <param name="生成的工具名称"></param>
  25. public HalconToolInterface(string toolName)
  26. {
  27. enable = true;
  28. toolType = ToolType.HalconTool;
  29. this.toolName = toolName;
  30. tool = new HalconTool.HalconTool();
  31. FormTool = null;
  32. FormToolName = "HalconTool.FormHalconTool";
  33. toolInput = new List<ToolIO>();
  34. toolOutput = new List<ToolIO>() { outputImage };
  35. }
  36. /// <summary>
  37. /// 只获取选择工具的描述信息..
  38. /// </summary>
  39. public HalconToolInterface()
  40. {
  41. toolDescription = "Halcon采集图像接口,可直接连接网口、USB等相机";
  42. }
  43. }
  44. [Serializable]
  45. [VisionToolAttribute(ToolType.SDKBasler)]
  46. public class SDKBaslerInterface : IToolInfo
  47. {
  48. // 必添加输出项
  49. ToolIO outputImage = new ToolIO("OutputImage", null, DataType.Image);
  50. /// <summary>
  51. /// 获取工具的所有信息
  52. /// </summary>
  53. /// <param name="生成的工具名称"></param>
  54. public SDKBaslerInterface(string toolName)
  55. {
  56. enable = true;
  57. toolType = ToolType.HalconTool;
  58. this.toolName = toolName;
  59. tool = new HalconTool.HalconTool();
  60. FormTool = null;
  61. FormToolName = "SDKBaslerTool.FormSDKBaslerTool";
  62. toolInput = new List<ToolIO>();
  63. toolOutput = new List<ToolIO>() { outputImage };
  64. }
  65. /// <summary>
  66. /// 只获取选择工具的描述信息..
  67. /// </summary>
  68. public SDKBaslerInterface()
  69. {
  70. toolDescription = "Basler相机采集图像接口,可直接连接网口、USB等Basler相机";
  71. }
  72. }
  73. [Serializable]
  74. [VisionToolAttribute(ToolType.FindLine)]
  75. public class FindLineToolInterface : IToolInfo
  76. {
  77. ToolIO inputImage = new ToolIO("InputImage", null, DataType.Image);
  78. ToolIO inputPos = new ToolIO("InputPos", null, DataType.Pose);
  79. ToolIO outputXld = new ToolIO("outputXld", null, DataType.Line);
  80. ToolIO startPointRow = new ToolIO("StartPointRow", null, DataType.IntValue);
  81. ToolIO startPointColumn = new ToolIO("StartPointColumn", null, DataType.IntValue);
  82. ToolIO endPointRow = new ToolIO("EndPointRow", null, DataType.IntValue);
  83. ToolIO endPointColumn = new ToolIO("EndPointColumn", null, DataType.IntValue);
  84. public FindLineToolInterface(string toolName)
  85. {
  86. enable = true;
  87. toolType = ToolType.FindLine;
  88. this.toolName = toolName;
  89. tool = new FindLine();
  90. FormToolName = "FindLineTool.FormFindLine";
  91. FormTool = null;
  92. toolInput = new List<ToolIO>() { inputImage, inputPos };
  93. toolOutput = new List<ToolIO>() { outputXld, startPointRow, startPointColumn, endPointRow, endPointColumn };
  94. }
  95. /// <summary>
  96. /// 只获取选择工具的描述信息
  97. /// </summary>
  98. public FindLineToolInterface()
  99. {
  100. toolDescription = "找线工具";
  101. }
  102. }
  103. [Serializable]
  104. [VisionToolAttribute(ToolType.Caliper)]
  105. public class CaliperInterface : IToolInfo
  106. {
  107. ToolIO inputImage = new ToolIO("InputImage", null, DataType.Image);
  108. ToolIO inputPos = new ToolIO("InputPos", null, DataType.Pose);
  109. ToolIO inputCenterRow = new ToolIO("inputCenterRow", null, DataType.IntValue);
  110. ToolIO inputCenterColumn = new ToolIO("inputCenterColumn", null, DataType.IntValue);
  111. ToolIO inputPhi = new ToolIO("inputPhi", null, DataType.IntValue);
  112. ToolIO outputCenterRow = new ToolIO("outputCenterRow", null, DataType.IntValue);
  113. ToolIO outputCenterColumn = new ToolIO("outputCenterColumn", null, DataType.IntValue);
  114. public CaliperInterface(string toolName)
  115. {
  116. enable = true;
  117. toolType = ToolType.Caliper;
  118. this.toolName = toolName;
  119. tool = new Caliper();
  120. FormToolName = "CaliperTool.FormCaliper";
  121. FormTool = null;
  122. toolInput = new List<ToolIO>() { inputImage, inputCenterRow, inputCenterColumn, inputPhi , inputPos };
  123. toolOutput = new List<ToolIO>() { outputCenterRow, outputCenterColumn };
  124. }
  125. /// <summary>
  126. /// 只获取选择工具的描述信息
  127. /// </summary>
  128. public CaliperInterface()
  129. {
  130. toolDescription = "卡尺工具";
  131. }
  132. }
  133. [Serializable]
  134. [VisionToolAttribute(ToolType.BlobAnalyse)]
  135. public class BlobAnalyseToolInterface : IToolInfo
  136. {
  137. }
  138. [Serializable]
  139. [VisionToolAttribute(ToolType.HDevEngineTool)]
  140. public class HDevEngineToolToolInterface : IToolInfo
  141. {
  142. ToolIO inputImage = new ToolIO("InputImage", null, DataType.Image);
  143. ToolIO inputPos = new ToolIO("InputPos", null, DataType.Pose);
  144. ToolIO outObject = new ToolIO("OutObject", null, DataType.Object);
  145. public HDevEngineToolToolInterface(string toolName)
  146. {
  147. enable = true;
  148. toolType = ToolType.HDevEngineTool;
  149. this.toolName = toolName;
  150. tool = new HDevEngineCode();
  151. FormToolName = "HDevEngineTool.FormHDevEngineTool";
  152. FormTool = null;
  153. toolInput = new List<ToolIO>() { inputImage, inputPos };
  154. toolOutput = new List<ToolIO>() { outObject };
  155. }
  156. /// <summary>
  157. /// 只获取选择工具的描述信息
  158. /// </summary>
  159. public HDevEngineToolToolInterface()
  160. {
  161. toolDescription = "使用Halcon引擎直接调用Halcon hdev代码";
  162. }
  163. }
  164. [Serializable]
  165. [VisionToolAttribute(ToolType.PMAlignTool)]
  166. public class PMAlignToolToolInterface : IToolInfo
  167. {
  168. ToolIO inputImage = new ToolIO("InputImage", null, DataType.Image);
  169. ToolIO outPose = new ToolIO("GetPose", null, DataType.Pose);
  170. ToolIO outPoseX = new ToolIO("GetPose.X", null, DataType.IntValue);
  171. ToolIO outPoseY = new ToolIO("GetPose.Y", null, DataType.IntValue);
  172. ToolIO outPoseR = new ToolIO("GetPose.Z", null, DataType.DoubleValue);
  173. ToolIO outPoseScore = new ToolIO("GetPose.Score", null, DataType.DoubleValue);
  174. public PMAlignToolToolInterface(string toolName)
  175. {
  176. enable = true;
  177. toolType = ToolType.PMAlignTool;
  178. this.toolName = toolName;
  179. tool = new PMAlign();
  180. FormToolName = "PMAlignTool.FormPMAlignTool";
  181. FormTool = null;
  182. toolInput = new List<ToolIO>() { inputImage };
  183. toolOutput = new List<ToolIO>() { outPose, outPoseX, outPoseY, outPoseR, outPoseScore };
  184. }
  185. /// <summary>
  186. /// 只获取选择工具的描述信息
  187. /// </summary>
  188. public PMAlignToolToolInterface()
  189. {
  190. toolDescription = "模板匹配工具,可得到根据图像捕获特征的姿态";
  191. }
  192. }
  193. [Serializable]
  194. [VisionToolAttribute(ToolType.EyeHandCalib)]
  195. public class EyeHandCalibrationInterface : IToolInfo
  196. {
  197. ToolIO inputPoint = new ToolIO("InputPoint", null, DataType.Point);
  198. ToolIO outPose = new ToolIO("GetPose", null, DataType.Pose);
  199. ToolIO outPoint = new ToolIO("OutPoint", null, DataType.Point);
  200. public EyeHandCalibrationInterface(string toolName)
  201. {
  202. enable = true;
  203. toolType = ToolType.EyeHandCalib;
  204. this.toolName = toolName;
  205. tool = new EyeHandCalib();
  206. FormToolName = "EyeHandCalibTool.FormEyeHandCalib";
  207. FormTool = null;
  208. toolInput = new List<ToolIO> { inputPoint };
  209. toolOutput = new List<ToolIO>() { outPose,outPoint};
  210. }
  211. /// <summary>
  212. /// 只获取选择工具的描述信息
  213. /// </summary>
  214. public EyeHandCalibrationInterface()
  215. {
  216. toolDescription = "手眼标定工具,根据输入的图像坐标和机械坐标可测得姿态";
  217. }
  218. }
  219. }