Skip to content

Commit

Permalink
Include OpenCV imgcodecs instead of highgui in examples
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
patrikhuber authored Dec 8, 2024
1 parent 2d44a21 commit ce60ed7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion examples/fit-model-ceres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion examples/fit-model-multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/fit-model-simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <iostream>
#include <vector>
Expand Down
2 changes: 1 addition & 1 deletion examples/fit-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <iostream>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion examples/generate-obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <iostream>

Expand Down

0 comments on commit ce60ed7

Please sign in to comment.