From ce60ed73608865a555c5e5d1510fd0bd131acf62 Mon Sep 17 00:00:00 2001 From: Patrik Huber Date: Sun, 8 Dec 2024 12:06:10 +0000 Subject: [PATCH] Include OpenCV imgcodecs instead of highgui in examples It looks like cv::imwrite was in highgui in OpenCV2, thus we included that header. But for a while now, it's been in imgcodecs. Thus if OpenCV 3 or 4 is found, we were only looking for (and linking to) imgcodecs, but not highgui - but we were still including the highgui header, and this leads to a compiler error in most recent builds. --- examples/CMakeLists.txt | 4 ++-- examples/fit-model-ceres.cpp | 2 +- examples/fit-model-multi.cpp | 3 ++- examples/fit-model-simple.cpp | 2 +- examples/fit-model.cpp | 2 +- examples/generate-obj.cpp | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9abf5273..ce7f1565 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -7,10 +7,10 @@ if("${OpenCV_VERSION_MAJOR}$" EQUAL 2) message(STATUS "OpenCV 2.x detected") find_package(OpenCV 2.4.3 REQUIRED core imgproc highgui) elseif("${OpenCV_VERSION_MAJOR}$" EQUAL 3) - message(STATUS "OpenCV 3.x detected - including imgcodecs for compatibility") + message(STATUS "OpenCV 3.x detected") find_package(OpenCV 3 REQUIRED core imgproc imgcodecs) elseif("${OpenCV_VERSION_MAJOR}$" EQUAL 4) - message(STATUS "OpenCV 4.x detected - including imgcodecs for compatibility") + message(STATUS "OpenCV 4.x detected") find_package(OpenCV 4 REQUIRED core imgproc imgcodecs) endif() # This allows us to compile in RelWithDebInfo. It'll use the Release-version of OpenCV: diff --git a/examples/fit-model-ceres.cpp b/examples/fit-model-ceres.cpp index 45fd41b0..baebceb4 100644 --- a/examples/fit-model-ceres.cpp +++ b/examples/fit-model-ceres.cpp @@ -37,7 +37,7 @@ #include "opencv2/core/core.hpp" #include "opencv2/imgproc/imgproc.hpp" -#include "opencv2/highgui/highgui.hpp" +#include "opencv2/imgcodecs/imgcodecs.hpp" #include "boost/filesystem.hpp" #include "boost/program_options.hpp" diff --git a/examples/fit-model-multi.cpp b/examples/fit-model-multi.cpp index e6dcbe2a..e3c021fe 100644 --- a/examples/fit-model-multi.cpp +++ b/examples/fit-model-multi.cpp @@ -33,7 +33,8 @@ #include "eos/cpp17/optional.hpp" #include "opencv2/core/core.hpp" -#include "opencv2/highgui/highgui.hpp" +#include "opencv2/imgproc/imgproc.hpp" +#include "opencv2/imgcodecs/imgcodecs.hpp" #include "boost/program_options.hpp" #include "boost/filesystem.hpp" diff --git a/examples/fit-model-simple.cpp b/examples/fit-model-simple.cpp index 91564d31..dcde3e86 100644 --- a/examples/fit-model-simple.cpp +++ b/examples/fit-model-simple.cpp @@ -35,8 +35,8 @@ #include "boost/program_options.hpp" #include "opencv2/core/core.hpp" -#include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" +#include "opencv2/imgcodecs/imgcodecs.hpp" #include #include diff --git a/examples/fit-model.cpp b/examples/fit-model.cpp index 5cf5ba46..15ecd2ff 100644 --- a/examples/fit-model.cpp +++ b/examples/fit-model.cpp @@ -36,8 +36,8 @@ #include "boost/program_options.hpp" #include "opencv2/core/core.hpp" -#include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" +#include "opencv2/imgcodecs/imgcodecs.hpp" #include #include diff --git a/examples/generate-obj.cpp b/examples/generate-obj.cpp index 5418ee48..1f9c0d26 100644 --- a/examples/generate-obj.cpp +++ b/examples/generate-obj.cpp @@ -30,7 +30,7 @@ #include "boost/program_options.hpp" #include "opencv2/core/core.hpp" -#include "opencv2/highgui/highgui.hpp" +#include "opencv2/imgcodecs/imgcodecs.hpp" #include