How to Run a HALCON Sample

Introduction

This tutorial shows how to configure HALCON samples and run them in HDevelop, C++, and C#.

Requirements

Required

Note

The HALCON version tested with Zivid cameras is 19.05 Progress, 20.05 Progress, 21.11 Progress.

Optional

  • 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.

Instructions

Step by step instructions are provided with screenshots below.

Configure environment variables for 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#.

Some environment variables needs to be set before you can begin to use Zivid with GenICam. There are two options:

On your PC, navigate to SystemAdvanced System SettingsEnvironmental Variables

System properties

Under System variables, select Path variable and click Edit… (Do not click New at this stage or you will overwrite the existing value of the Path system variable!) and then add the following value by clicking New:

Variable name

Path

Variable value

C:\Program Files\Zivid\bin

Environment variables highlighting edit

Note

Ensure to have the correct path for your Zivid installation.

Click OK to go back to the Environment variables window and then click New to include the following system variable:

Variable name:

GENICAM_GENTL64_PATH

Variable value

C:\Program Files\Zivid\bin

Environment variables highlighting new
Adding new system variable

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.

Note

All HDevelop samples are located inside the source/hdev folder

Open the sample that you would like to run, e.g. CaptureHDR.hdev.

HALCON sample program script in HDevelop

Run the program by pressing the F5 key. The program should now run successfully and display the 3D point cloud of your scene.

Sample view of point cloud in 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.

Note

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