如何运行HALCON示例
介绍
本教程展示了如何配置HALCON示例并在HDevelop、C++ 和 C#中运行它们。
要求
必需的
备注
用于测试Zivid相机的HALCON版本为19.05 Progress、20.05 Progress、21.11 Progress。
可选的
If you do not currently have a separate ply viewer installed, MeshLab is a straight forward option to see the point clouds generated from the samples provided.
说明
下面的屏幕截图提供了分步说明。
为GenICam/HALCON配置环境变量
If you have already done this, you can skip to Run HALCON samples using HDevelop or Build and run HALCON samples using C++ or C#.
在开始将Zivid与GenICam一起使用之前,需要设置一些环境变量。有两种选择:
Run HALCON samples using HDevelop
Now that your environment variables are set, we are ready to run samples! The video below shows you how to run samples using Zivid camera in HALCON.
Open HDevelop, and click on Open Program. Go to the location where you downloaded the samples. If you have not downloaded them, you can do this from zivid-halcon-samples.
备注
All HDevelop samples are located inside the source/hdev
folder
打开您要运行的示例,例如*CaptureHDR.hdev*。
![HDevelop中的HALCON示例程序脚本](../../../_images/halcon_samples_capture_hdr.png)
按 F5 键运行程序。该程序现在应该能够成功运行并显示场景的3D点云。
![HDevelop中的点云示例视图](../../../_images/halcon_sample_view_point_cloud.png)
Build and run HALCON samples using C++ or C#
Select your language:
To run C++ HALCON samples, we will use CMake to configure the samples.
备注
All C++ samples are located inside the source/cpp
folder
Run CMake (cmake-gui.exe), then set the top two entries:
Where is the source code |
|
Where to build the binaries |
|
![cmake after setting source and build path](../../../_images/cmake_halcon_setting_source_build_path.png)
Click Configure. When prompted, click Yes to create a new build directory.
![cmake pop-up create directory](../../../_images/cmake_halcon_build_create_directory.png)
Specify the generator for this project |
|
Optional platform for generator |
|
![cmake when specifying generator for project](../../../_images/cmake_specify_generator_visual_studio.png)
Click Finish.
Then click on Configure, Generate, and Open Project.
To build and run samples, you must first change the build configuration from Debug to Release. Build the solution by pressing Ctrl + Shift + B.
To run the sample, navigate to the Release folder in File Explorer and double click on the sample you want to run.
![Release folder for c++ samples](../../../_images/halcon_samples_cpp_build_release_folder.png)
备注
All C# samples are located inside the source/csharp
folder
Navigate to the sample folder location you saved the samples and open one of the samples, e.g. CaptureHalconViaZivid.cs.
![HALCON capture via zivid script in Visual Studio](../../../_images/zivid_halcon_sample_capture_via_zivid.png)
To build and run samples, you must first change the build configuration from Debug to Release. Build the solution by pressing Ctrl + Shift + B.
To run the sample, navigate to the Release folder in File Explorer and double click on the sample you want to run.
![Release folder for c# samples](../../../_images/halcon_samples_csharp_release_folder.png)