Skip to content

Compatibility with OpenCV 4

Cédric Traizet requested to merge compatibility_opencv4 into develop


Changes to make OTB compatible with OpenCV 4. The SuperBuild OpenCV version has been upgraded to v4.1.1

This MR doesn't remove compatibility with open CV 2, but maybe we should drop it, see issue #1954 (closed).


OpenCV 4 has been released, we need to make OTB compatible with it !

The main change of OpenCV4 is the use of C++ 11.

Implementation Details

The SuperBuild code has been modified to use open cv 4.1.1. The OpenCV patch has been updated.

The OTB_OPENCV_4 cmake variable has been defined and is true when the openCV major version number is 4. OTB_OPENCV_3 is true for both openCV 3 and openCV 4.

The neural network machine learning model has been updated to use cv::Mat instead of the c class CvMat (deprecated since open cv 2...). In OpenCV4 CvMat can't be serialized easily, which is an issue when saving/loading the model.

The GetVote method of CvRTreeWrapper has been implemented, as it is pure virtual in opencv4.


The copyright owner is CNES and has signed the ORFEO ToolBox Contributor License Agreement.

Check before merging:

  • All discussions are resolved
  • At least 2 👍 votes from core developers, no 👎 vote.
  • The feature branch is (reasonably) up-to-date with the base branch
  • Dashboard is green
  • Copyright owner has signed the ORFEO ToolBox Contributor License Agreement
  • Optionally, run git diff develop... -U0 --no-color | -p1 -i on latest changes and commit
Edited by Cédric Traizet

Merge request reports