ImageDev C++
This section details how to start with ImageDev C++.
ImageDev C++ can be installed with a package archives.
You must first build the "install" project to copy the ImageDev libraries in the output directory.
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
Creating a build environment from package archives
To create a new project using ImageDev from an available package archive, you need to:- Download the ImageDevC++ and ImageDevExamplesC++ package archives corresponding to your OS and compiler.
- Unzip these archives in a folder.
- 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:
- Replace in the CMakeLists.txt file:
-
- path_to_unzipped_ImageDev by the path to the unziped ImageDevC++ folder
- path_to_unzipped_ImageDevExamples by the path to the unziped ImageDevExamplesC++ folder
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.
- Press the "Generate" button.
Hello ImageDev C++
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 are now ready to write your first ImageDev code, for instance by copying and pasting the content of the main function of the C++ example available at the end of the HelloImageDev tutorial page.
You must first build the "install" project to copy the ImageDev libraries in the output directory.
You can now run this code and compare the resulting images with those shown in the HelloImageDev tutorial.