This directory contains a selection of example programs demonstrating the use of the IC Imaging Control 4 C++ API.
Most of the examples focus on a particular aspect of writing software to control a camera. Others, like qt6/demoapp are small complete application programs.
To download all examples in a .zip file, move to the root of the repository, click the green Code button and select Download ZIP.
You can also select Open with Visual Studio to clone the examples into a directory on your computer, or use git directly.
After downloading, please make sure to keep the per-language directory structure intact so that relative file references can work.
Warning: Be careful when cloning/extracting to a directory with a long path name; many tools are still limited by Windows' legacy 260-character path length limit and can raise obscure error messages in case a file path exceeds it.
All examples assume you have access to an industrial camera from The Imaging Source.
Make sure a GenTL Producer matching your camera is installed.
All C++ examples assume that the IC4 SDK for C++ is installed. For Windows, this means installing IC Imaging Control 4 SDK from the website. For Linux, all debian packages from ic4.tar.gz should be installed.
The examples require CMake (On Windows, this is provided by Visual Studio 2019 or later) and a C++ compiler supporting at least C++14.
Some example programs make use of Qt to provide a user interface. On Windows, please make sure to install the Qt component matching your compiler; e.g. when compiling the example programs using Microsoft Visual Studio 2022, customize the Qt Online Installer to include the MSVC 2022 64-bit component. On Debian-based Linux systems, install the qt6-base-dev package.
Most examples are built using CMake. You can either manually use CMake to build the example programs, or use an IDE that knows how to build CMake projects.
A group of example programs can be compiled by running CMake in one of the parent directories containing a CMakeLists.txt file.
Please note that programs depending on third-party libraries like Qt or OpenCV will not be built unless the respective libraries are found.
Visual Studio natively support CMake' projects from version 2019 onwards.
From the main menu, select File -> Open... -> Folder... and navigate to a directory containing a CMakeLists.txt file.
After the project was configured successfully, select the example executable you want to build and run from Select Startup Item... dropdown next to the Start Debugging button.
Click Start Debugging and the program will be compiled and run.
First, enter a directory containing a CMakeLists.txt file.
This can either be one of the top-level directories
containing multiple projects, or one of the project-specific
directories.
Specify a build directory for cmake and generate files for the build system:
~/ic4-examples/cpp/device-handling/device-enumeration $ cmake -B build/ .
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
(...)
-- Configuring done (1.3s)
-- Generating done (0.0s)
-- Build files have been written to: ~/ic4-examples/cpp/device-handling/device-enumeration/build
Now build the application:
~/ic4-examples/cpp/device-handling/device-enumeration $ cmake --build build/
[ 50%] Building CXX object CMakeFiles/device-enumeration.dir/src/device-enumeration.cpp.o
[100%] Linking CXX executable device-enumeration
[100%] Built target device-enumeration
Now run the example program:
~/ic4-examples/cpp/device-handling/device-enumeration $ ./build/device-enumeration
If everything worked, the program will now show that your camera was detected!
The example programs are grouped by topic for clarity.
These examples show how to
- enumerate devices and interfaces
- Get device-list-changed notifications
- Handle device-lost events
This section contains example programs showing how to capture and
- Save images as JPEG files
- Record videos as H264-encoded MP4 files
- Save BMP files on trigger.
- Measure framerate of cameras.
Some cameras provide advanced features that can be utilized to solve specific application requirements. This section showcases
- Triggering multiple cameras simultaneously by broadcasting an action command
- Reading camera-provided metadata from image buffers using chunkdata
- Using EventExposureEnd to synchronize camera operation to real-world movement
- Get notified about I/O activity using EventLine1*Edge events
This section contains example programs showing camera specific functions
- DoLP Segmentation shows how to visualize the degree of polarized light with polarisation cameras.
The Qt6 section provides a selection of pre-build dialogs that can speed up application development:
- The PropertyDialog class allows the user to quickly find and modify the features of a video capture device or other components.
- DeviceSelectionDialog is a dialog allowing device selection and configuration.
Several complete applications are also found here:
- demoapp contains the source code of the ic4-demoapp application distributed with the IC Imaging Control4 SDK.
- device-manager contains the source code of the ic4-device-manager application distributed with the IC Imaging Control4 SDK.
- high-speed-capture is an example program showing how to use many image buffers to capture image data into memory for potentially slow processing tasks.
This section contains programs showing how to use data captured in ImageBuffer objects with third-party image processing libraries:
Contains a small demo application using MFC. This example is using traditional .sln and .vcxproj files for Visual Studio.
This is the source code for the ic4-ctrl utility distributed with the IC Imaging Control4 SDK.