#7141·opentoonz

Build failure with OpenCV 5.0: getRotationMatrix2D / getOptimalNewCameraMatrix relocated to new headers

Author: dingowizardCreated Sep 24, 2026Updated Sep 27, 2026
Labelsbug

Building current master against OpenCV 5.0.0 fails with two separate errors, both because OpenCV 5 reorganized parts of imgproc/calib3d into new headers that aren't pulled in by the existing #include <opencv2/opencv.hpp> includes in these files:

toonz/sources/stdfx/iwa_bloomfx.cpp:36:21: error: 'getRotationMatrix2D' is not a member of 'cv' toonz/sources/stdfx/iwa_bloomfx.cpp:44:16: error: 'getRotationMatrix2D' is not a member of 'cv' toonz/sources/toonz/penciltestpopup.cpp:2775:35: error: 'getOptimalNewCameraMatrix' is not a member of 'cv'

In OpenCV 5.0, cv::getRotationMatrix2D moved to opencv2/geometry/2d.hpp, and cv::getOptimalNewCameraMatrix moved to opencv2/geometry/3d.hpp. Neither is re-exported by opencv2/opencv.hpp (verified against the installed OpenCV 5.0.0 headers on Arch Linux), so any file relying on the umbrella include no longer sees them.

Fix: add version-guarded includes for the new headers.

diff --git a/toonz/sources/stdfx/iwa_bloomfx.h b/toonz/sources/stdfx/iwa_bloomfx.h --- a/toonz/sources/stdfx/iwa_bloomfx.h +++ b/toonz/sources/stdfx/iwa_bloomfx.h @@ -16,6 +16,9 @@ value #include "stdfx.h" #include "tfxparam.h" #include <opencv2/opencv.hpp> +#if CV_VERSION_MAJOR >= 5 +#include <opencv2/geometry/2d.hpp> +#endif

class Iwa_BloomFx : public TStandardRasterFx { FX_PLUGIN_DECLARATION(Iwa_BloomFx) diff --git a/toonz/sources/toonz/penciltestpopup.h b/toonz/sources/toonz/penciltestpopup.h --- a/toonz/sources/toonz/penciltestpopup.h +++ b/toonz/sources/toonz/penciltestpopup.h @@ -7,6 +7,9 @@ #include "toonzqt/lineedit.h" #include "toonz/namebuilder.h" #include "opencv2/opencv.hpp" +#if CV_VERSION_MAJOR >= 5 +#include <opencv2/geometry/3d.hpp> +#endif #include "tfilepath.h" #include "toonz/tproject.h" #include "filebrowserpopup.h"

Tested: with this patch applied, master builds and links cleanly against OpenCV 5.0.0 (confirmed on Arch Linux, GCC).

Environment: Arch Linux, OpenCV 5.0.0-12, GCC (current Arch toolchain), building via the CMake flow in toonz/sources/CMakeLists.txt (find_package(OpenCV REQUIRED)).