ImageDev C++
This section details how to start with ImageDev C++.
ImageDev C++ can be installed with a package archives.
You can now run this code and compare the resulting images with those shown in the HelloImageDev tutorial.
Prerequisites
Supported platforms
To use ImageDev in a C++ project you need:- On Windows: Visual studio 2015 or greater
- On Linux: GCC 7 compiler or greater
- CMake 3.7 or greater, 64-bits
Package Deployment
- Download the ImageDevC++ and ImageDevExamplesC++ package archives corresponding to your OS and compiler.
- Unzip these archives in a folder.
- path_to_unzipped_ImageDev is the path to the unzipped ImageDevC++ folder
- path_to_unzipped_ImageDevExamples is the path to the unzipped ImageDevExamplesC++ folder
Creating a new project linked to ImageDev
Build environment from package archives
To create a new project using ImageDev from package archives, you need to:- Define a sources folder containing:
- a CMakeLists.txt file with the following instructions:
cmake_minimum_required( VERSION 3.7 ) # Project name project( HelloImageDev ) # ----------------------------------------------------------------------- # Define the directories containing data from the unzipped archives. set( ImageDev_DIR "path_to_unzipped_ImageDev/cmake" ) set( ImageDevExamples_DIR "path_to_unzipped_ImageDevExamples/cmake" ) # Find ImageDev and ImageDevExamples find_package( ImageDev REQUIRED ) find_package( ImageDevExamples REQUIRED ) # ----------------------------------------------------------------------- set( CMAKE_CXX_STANDARD 11 ) if ( UNIX ) set( CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}" ) endif() add_executable( ${PROJECT_NAME} main.cpp ) target_link_libraries( ${PROJECT_NAME} PUBLIC ImageDev ImageDevExamples ) if ( UNIX ) # Change the output directory if ( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) set_property( TARGET ${PROJECT_NAME} PROPERTY RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}" ) else() set_property( TARGET ${PROJECT_NAME} PROPERTY RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}" ) endif() endif() # Install the ImageDev libraries in the output directory install( FILES ${ImageDev_ALL_BINARIES_DEBUG} DESTINATION ${CMAKE_BINARY_DIR}/Debug CONFIGURATIONS Debug ) install( FILES ${ImageDev_ALL_BINARIES_RELEASE} DESTINATION ${CMAKE_BINARY_DIR}/Release CONFIGURATIONS Release ) # Install the libraries used by the demonstration in the output directory install( DIRECTORY ${ImageDevExamples_BINS_DIRECTORY_DEBUG} DESTINATION ${CMAKE_BINARY_DIR}/Debug CONFIGURATIONS Debug ) install( DIRECTORY ${ImageDevExamples_BINS_DIRECTORY_RELEASE} DESTINATION ${CMAKE_BINARY_DIR}/Release CONFIGURATIONS Release )
- a main.cpp file, for instance with a minimal main function:
int main() { return 0; }
- a CMakeLists.txt file with the following instructions:
- In the CMakeLists.txt file, replace path_to_unzipped_ImageDev and path_to_unzipped_ImageDevExamples by the appropriate paths.
Project configuration
- Open CMake.
- Select the sources folder previously created with the "Browse Source..." button.
- Select an empty build folder with the "Browse Build..." button.
- Press the "Configure" button.
- Select the appropriate generator, corresponding to your compiler and architecture.
- If your generator is more recent than Visual Studio 15 2017, you need to specify an optionnal toolset:
- For Visual Studio 16 2019: v142
- For Visual Studio 17 2022: v141
- Press the "Finish" button.
- Press the "Generate" button.
Start using ImageDev
To create your first ImageDev processing code, you need to open or create a C++ project generated with the CMake options and add the following directives for including ImageDev, IOLink and IOFormat headers and namespaces.#include <ImageDev/ImageDev.h> #include <ioformat/IOFormat.h> #include <iolink/view/ImageViewProvider.h> using namespace imagedev; using namespace ioformat; using namespace iolink;You must first build the "install" project to copy the ImageDev libraries in the output directory.
Launching the ImageDev examples
All tutorials of the ImageDev user guide are available in the ImageDevExamplesC++ package. This section describes how to launch these examples.Project configuration
- Define an IMAGEDEVHOME environment variable with the path_to_unzipped_ImageDev value.
- Open CMake.
- Select the path_to_unzipped_ImageDevExamples/examples/source folder with the "Browse Source..." button.
- Select an empty build folder with the "Browse Build..." button.
- Press the "Configure" button.
- Select the appropriate generator, corresponding to your compiler and architecture.
- If your generator is more recent than Visual Studio 15 2017, you need to specify an optionnal toolset:
- For Visual Studio 16 2019: v142
- For Visual Studio 17 2022: v141
- Press the "Finish" button.
- Press the "Generate" button.
Hello ImageDev C++
You are now ready to run your first ImageDev code.- Build the "INSTALL" project to copy the ImageDev libraries in the output directory.
- Set the T01_01_HelloImageDev project as StartUp Project.
- Start the project execution.
You can now run this code and compare the resulting images with those shown in the HelloImageDev tutorial.