I have two Opencvs, opencv-2.4.10 is installed in /usr and opencv-3.1 is installed in /usr/local. I can set the opencv path in Eclipse easily. In cmake, how can I set the path for one of the opencvs I like to use for that project? Thanks
相关问题
- How to get the background from multiple images by
- Try to load image with Highgui.imread (OpenCV + An
- CV2 Image Error: error: (-215:Assertion failed) !s
- Is it a bug of opencv RotatedRect?
- How do I apply a perspective transform with more t
相关文章
- opencv fails to build with ipp support enabled
- Code completion is not working for OpenCV and Pyth
- Target requires the language dialect “CXX17” (with
- Face unlock code in Android open source project?
- How to compile a c++ application using static open
- Why cv2.rectangle sometimes return np.ndarray, whi
- How do I tell cmake not to create a console window
- Fastest way to compute image dataset channel wise
I don't have a Linux machine to test it on but this is how I do it on Windows 10 64bit.
I only added a line in the
CmakeLists.txt
in my program to set the variableOpenCV_DIR
used by CMake.For example, if OpenCV is installed in
C:/opencv
, I addin my
CMakeLists.txt
.In your case, it should be something like
But, as I said, I never tested this on Linux.
None of the other answers worked for me (linux, opencv 4.0.0, haven't tested yet with opencv 3.x.x).
Adding the following before the line
find_package(...)
in the CMakeLists.txt worked:set(OpenCV_DIR /path/to/opencv_install_dir/lib/cmake/opencv4)
If opencv was compiled from source with a none standard installation target directory, then
/path/to/opencv_install_dir
is (should be) known, otherwise search for the location of the directory structurelib/cmake/opencv*
.This question is a duplicate of How to force c++ compiler use one of different installed package's versions, using CMake? but it is found by search engines so I add the answer from texasflood that I found to be working with CMake 2.8.12.2 and OpenCV 3.2.0 on Ubuntu 12.4:
Simply change the
find_package
command: