Using OpenCV in a CamiTK extension project
Although CamiTK Community Edition does not depends on OpenCV, if your extension requires OpenCV, this page presents the correct way of setting up, install and use OpenCV for a flawless integration.
Setup and install OpenCV
On Linux
On Ubuntu, Debian or derivatives, just install the dev package (typically using sudo apt install libopencv-dev
).
For other Linux distribution, please check that a package is available. Otherwise just refer to the OpenCV documentation or get inspired by the windows setup below. As OpenCV is also using CMake, it is a easy step.
On Windows
If you followed the Windows Setup guide, just fire up a command shell and type:
Configure your CEP to use OpenCV
On Linux, once installed, you need to provide the default installation directory when you run CMake configuration:
On Windows, OpenCV should be found by CMake as it should be installed in %CAMITK_INSTALL_DRIVE%\%CAMITK_INSTALL_ROOT%
(if you followed the above setup).
Declare the dependency of your extension
Do not forget to check or add the NEEDS_OPENCV
in your extension CMakeLists.txt
:
CamiTK CMake macro camitk_extension
will automatically do the configuration magic to include and link with OpenCV.
→ Now you are ready to use OpenCV C++ API in your extension!
If you want a more portable solution across Windows and Linux, you might need to add INCLUDE_DIRECTORIES ${OpenCV_INCLUDE_DIRS}/opencv4
in your camitk_extension
options. This way `#include <opencv2/opencv.hpp>" will work independently on the OpenCV version and operating system.
If you have already written some code using OpenCV in python, just extract the processing part and translate it to C++ (it is usually a direct process). This will probably improve the performance, user experience, long-term support and reproducibility of your code.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.