Set Opencv path for a c++ project using Cmake

后端 未结 3 1262
没有蜡笔的小新
没有蜡笔的小新 2021-02-15 17:24

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 f

3条回答
  •  梦谈多话
    2021-02-15 18:18

    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 variable OpenCV_DIR used by CMake.

    For example, if OpenCV is installed in C:/opencv, I add

    SET("OpenCV_DIR" "C:/opencv")
    

    in my CMakeLists.txt.

    In your case, it should be something like

    SET("OpenCV_DIR" "/usr/opencv-2.4.10")
    

    But, as I said, I never tested this on Linux.

提交回复
热议问题