如何运行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一起使用之前,需要设置一些环境变量。有两种选择:

在您的PC上,导航到 系统高级系统设置环境变量

系统属性

系统变量 下,选 择 Path 变量并单击 编辑… (不要点击 新建,否则您将覆盖Path系统变量的现有值!),然后通过单 击 新建 添加以下变量:

变量名

Path

变量值

C:Program FilesZividbin

环境变量高亮编辑

备注

确保输入的Zivid安装路径是正确的。

点 击 确定 返回到环境变量窗口,然后单 击 新建 包括以下系统变量:

变量名:

GENICAM_GENTL64_PATH

变量值

C:Program FilesZividbin

突出显示新的环境变量
添加新的系统变量

点击键盘上的 Win + R 键。然后输入*cmd*并按下 Enter

Windows运行命令

输入以下命令:

set PATH=%PATH%;C:\Program Files\Zivid\bin
set GENICAM_GENTL64_PATH=C:\Program Files\Zivid\bin
"%HALCONROOT%\bin\x64-win64\hdevelop.exe"

备注

确保为输入的HALCON和Zivid安装路径是正确的

在cmd中设置变量

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示例程序脚本

F5 键运行程序。该程序现在应该能够成功运行并显示场景的3D点云。

HDevelop中的点云示例视图

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

C:/Users/Public/Downloads/zivid-halcon-samples/source/cpp

Where to build the binaries

C:/Users/Public/Downloads/zivid-halcon-samples/source/cpp/build

cmake after setting source and build path

Click Configure. When prompted, click Yes to create a new build directory.

cmake pop-up create directory

Specify the generator for this project

Visual Studio 15 2017

Optional platform for generator

x64

cmake when specifying generator for project

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

备注

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

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