VisionPro如何编写自定义控件

上传者: 41793286 | 上传时间: 2024-08-22 08:05:56 | 文件大小: 13.11MB | 文件类型: 7Z
在计算机视觉领域,Cognex VisionPro是一款广泛应用的高级图像处理软件,它提供了丰富的工具集来帮助用户解决各种复杂的图像分析任务。为了满足特定需求或扩展功能,有时我们需要编写自定义控件。以下将详细介绍如何在VisionPro中创建自定义控件。 1. **创建项目**:你需要在Visual Studio环境中创建一个新的.NET类库项目。在这个例子中,项目名为"myCogTool"。打开Visual Studio,选择"文件" -> "新建" -> "项目",然后在模板列表中选择".NET Framework"下的"类库"类型。 2. **添加引用**:为使新项目与VisionPro兼容,需要添加对Cognex VisionPro SDK的引用。在"解决方案资源管理器"中右键点击"引用",选择"添加引用",在"浏览"选项卡中找到VisionPro安装目录下的SDK文件夹,通常为`C:\Program Files\Cognex\VisionPro SDK\vXXX\DotNet`,选择`CogTool.dll`和`CogToolInterop.dll`添加。 3. **编写自定义控件代码**:在新创建的类库中,定义一个继承自Cognex.CogTool.UserControlBase的类,这个基类提供了与VisionPro交互的基础。例如,你可以创建一个名为"ToVTT"的类,包含必要的属性、方法和事件处理程序。这些方法可以包括初始化控件、设置参数、执行图像处理等操作。 ```csharp using Cognex.CogTool; using System.Windows.Forms; public class ToVTT : UserControlBase { public ToVTT() { InitializeComponent(); } protected override void OnExecute(ExecuteEventArgs e) { // 在这里实现你的图像处理逻辑 } // 其他自定义方法和属性 } ``` 4. **设计用户界面**:在设计视图中,可以添加所需的控件如文本框、按钮等,用于用户输入参数或显示结果。记得设置控件的属性,并连接事件处理程序。 5. **编译和测试**:完成代码编写后,编译项目生成DLL文件。将生成的"myCogTool.dll"复制到VisionPro的`CogTools`目录下,通常是`C:\Program Files\Cognex\VisionPro\vXXX\Bin\CogTools`。现在,在VisionPro的工程中,你应该能看到新添加的自定义控件"myCogTool",可以将其拖放到流程图中进行测试。 6. **调试与优化**:在Visual Studio中设置VisionPro的可执行文件作为调试目标,这样可以直接在开发环境中调试自定义控件。通过反复测试和优化,确保控件的稳定性和性能。 7. **保存与分享**:一旦自定义控件开发完成,可以将其打包成`.vpt`文件,方便在其他VisionPro项目中复用。只需在VisionPro中右键点击工具箱,选择"保存工具箱",然后指定文件名,例如"myCogTool.vpt"。 编写自定义控件是提升VisionPro功能的关键步骤,它允许开发者根据具体应用需求定制工具,实现更高效、精确的图像处理任务。通过熟练掌握这一技术,可以大大提高你的工作效率并拓宽在计算机视觉领域的应用范围。

文件下载

资源详情

[{"title":"( 94 个子文件 13.11MB ) VisionPro如何编写自定义控件","children":[{"title":"myCogTool.sln <span style='color:#111;'> 1.56KB </span>","children":null,"spread":false},{"title":"ToVTT","children":[{"title":"Form1.Designer.cs <span style='color:#111;'> 1.43KB </span>","children":null,"spread":false},{"title":"ToVTT.csproj <span style='color:#111;'> 4.08KB </span>","children":null,"spread":false},{"title":"App.config <span style='color:#111;'> 187B </span>","children":null,"spread":false},{"title":"Form1.cs <span style='color:#111;'> 741B </span>","children":null,"spread":false},{"title":"obj","children":[{"title":"Debug","children":[{"title":"ToVTT.Form1.resources <span style='color:#111;'> 180B </span>","children":null,"spread":false},{"title":"TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"ToVTT.exe <span style='color:#111;'> 7.50KB </span>","children":null,"spread":false},{"title":"ToVTT.Properties.Resources.resources <span style='color:#111;'> 180B </span>","children":null,"spread":false},{"title":"ToVTT.csprojAssemblyReference.cache <span style='color:#111;'> 166.92KB </span>","children":null,"spread":false},{"title":"DesignTimeResolveAssemblyReferencesInput.cache <span style='color:#111;'> 7.30KB </span>","children":null,"spread":false},{"title":"TempPE","children":null,"spread":false},{"title":"ToVTT.csproj.CopyComplete <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"ToVTT.csproj.FileListAbsolute.txt <span style='color:#111;'> 2.98KB </span>","children":null,"spread":false},{"title":"TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"ToVTT.csproj.GenerateResource.cache <span style='color:#111;'> 1012B </span>","children":null,"spread":false},{"title":"ToVTT.pdb <span style='color:#111;'> 27.50KB </span>","children":null,"spread":false},{"title":"ToVTT.csproj.CoreCompileInputs.cache <span style='color:#111;'> 42B </span>","children":null,"spread":false}],"spread":false}],"spread":true},{"title":"bin","children":[{"title":"Debug","children":[{"title":"Cognex.VisionPro3D.Display.Controls.xml <span style='color:#111;'> 19.09KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro3D.Display.Controls.dll <span style='color:#111;'> 34.50KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro3D.Core.xml <span style='color:#111;'> 417.10KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.CorePlus.xml <span style='color:#111;'> 30.02KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.ImageFile.xml <span style='color:#111;'> 100.02KB </span>","children":null,"spread":false},{"title":"ToVTT.exe <span style='color:#111;'> 7.50KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro3D.Core.dll <span style='color:#111;'> 16.29MB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.Display.Controls.dll <span style='color:#111;'> 87.00KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.Core.dll <span style='color:#111;'> 9.62MB </span>","children":null,"spread":false},{"title":"myCogTool.dll <span style='color:#111;'> 6.50KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.xml <span style='color:#111;'> 385.93KB </span>","children":null,"spread":false},{"title":"stdole.dll <span style='color:#111;'> 31.63KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.dll <span style='color:#111;'> 245.50KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.ImageFile.dll <span style='color:#111;'> 307.00KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.Core.xml <span style='color:#111;'> 2.80MB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.Controls.dll <span style='color:#111;'> 2.10MB </span>","children":null,"spread":false},{"title":"ToVTT.exe.config <span style='color:#111;'> 187B </span>","children":null,"spread":false},{"title":"myCogTool.pdb <span style='color:#111;'> 21.50KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.ImageProcessing.xml <span style='color:#111;'> 758.77KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.FGGigE.xml <span style='color:#111;'> 93.08KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.Interop.Core.dll <span style='color:#111;'> 1.05MB </span>","children":null,"spread":false},{"title":"ToVTT.pdb <span style='color:#111;'> 27.50KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.ImageProcessing.dll <span style='color:#111;'> 7.10MB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.FGGigE.dll <span style='color:#111;'> 402.00KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.Display.Controls.xml <span style='color:#111;'> 132.74KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.CorePlus.dll <span style='color:#111;'> 6.91MB </span>","children":null,"spread":false},{"title":"myCogTool.vtt <span style='color:#111;'> 1.01KB </span>","children":null,"spread":false}],"spread":false}],"spread":true},{"title":"Properties","children":[{"title":"Resources.Designer.cs <span style='color:#111;'> 2.76KB </span>","children":null,"spread":false},{"title":"Settings.Designer.cs <span style='color:#111;'> 1.07KB </span>","children":null,"spread":false},{"title":"Settings.settings <span style='color:#111;'> 249B </span>","children":null,"spread":false},{"title":"AssemblyInfo.cs <span style='color:#111;'> 1.28KB </span>","children":null,"spread":false},{"title":"Resources.resx <span style='color:#111;'> 5.48KB </span>","children":null,"spread":false}],"spread":true},{"title":"Program.cs <span style='color:#111;'> 517B </span>","children":null,"spread":false},{"title":"Form1.resx <span style='color:#111;'> 5.68KB </span>","children":null,"spread":false}],"spread":true},{"title":"myCogTool","children":[{"title":"myCogToolEdit.resx <span style='color:#111;'> 5.68KB </span>","children":null,"spread":false},{"title":"myCogTool1.cs <span style='color:#111;'> 3.31KB </span>","children":null,"spread":false},{"title":"myCogToolEdit.Designer.cs <span style='color:#111;'> 1.34KB </span>","children":null,"spread":false},{"title":"obj","children":[{"title":"Debug","children":[{"title":"TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"myCogTool.csproj.CoreCompileInputs.cache <span style='color:#111;'> 42B </span>","children":null,"spread":false},{"title":"myCogTool.csprojAssemblyReference.cache <span style='color:#111;'> 170.85KB </span>","children":null,"spread":false},{"title":"myCogTool.dll <span style='color:#111;'> 6.50KB </span>","children":null,"spread":false},{"title":"DesignTimeResolveAssemblyReferencesInput.cache <span style='color:#111;'> 7.03KB </span>","children":null,"spread":false},{"title":"myCogTool.csproj.FileListAbsolute.txt <span style='color:#111;'> 2.82KB </span>","children":null,"spread":false},{"title":"TempPE","children":null,"spread":false},{"title":"myCogTool.pdb <span style='color:#111;'> 21.50KB </span>","children":null,"spread":false},{"title":"TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"myCogTool.myCogToolEdit.resources <span style='color:#111;'> 180B </span>","children":null,"spread":false},{"title":"myCogTool.csproj.CopyComplete <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"myCogTool.csproj.GenerateResource.cache <span style='color:#111;'> 947B </span>","children":null,"spread":false},{"title":"DesignTimeResolveAssemblyReferences.cache <span style='color:#111;'> 122.53KB </span>","children":null,"spread":false}],"spread":false}],"spread":true},{"title":"bin","children":[{"title":"Release","children":null,"spread":false},{"title":"Debug","children":[{"title":"Cognex.VisionPro3D.Display.Controls.xml <span style='color:#111;'> 19.09KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro3D.Display.Controls.dll <span style='color:#111;'> 34.50KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro3D.Core.xml <span style='color:#111;'> 417.10KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.CorePlus.xml <span style='color:#111;'> 30.02KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.ImageFile.xml <span style='color:#111;'> 100.02KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro3D.Core.dll <span style='color:#111;'> 16.29MB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.Display.Controls.dll <span style='color:#111;'> 87.00KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.Core.dll <span style='color:#111;'> 9.62MB </span>","children":null,"spread":false},{"title":"myCogTool.dll <span style='color:#111;'> 6.50KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.xml <span style='color:#111;'> 385.93KB </span>","children":null,"spread":false},{"title":"stdole.dll <span style='color:#111;'> 31.63KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.dll <span style='color:#111;'> 245.50KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.ImageFile.dll <span style='color:#111;'> 307.00KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.Core.xml <span style='color:#111;'> 2.80MB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.Controls.dll <span style='color:#111;'> 2.10MB </span>","children":null,"spread":false},{"title":"myCogTool.pdb <span style='color:#111;'> 21.50KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.ImageProcessing.xml <span style='color:#111;'> 758.77KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.FGGigE.xml <span style='color:#111;'> 93.08KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.Interop.Core.dll <span style='color:#111;'> 1.05MB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.ImageProcessing.dll <span style='color:#111;'> 7.10MB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.FGGigE.dll <span style='color:#111;'> 402.00KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.Display.Controls.xml <span style='color:#111;'> 132.74KB </span>","children":null,"spread":false},{"title":"Cognex.VisionPro.CorePlus.dll <span style='color:#111;'> 6.91MB </span>","children":null,"spread":false}],"spread":false}],"spread":true},{"title":"Properties","children":[{"title":"AssemblyInfo.cs <span style='color:#111;'> 1.29KB </span>","children":null,"spread":false}],"spread":true},{"title":"myCogToolEdit.cs <span style='color:#111;'> 801B </span>","children":null,"spread":false},{"title":"myCogTool.csproj <span style='color:#111;'> 2.98KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明