1. 程式人生 > >mac10.12.6系統配置clion編寫CMakeLists文件運行opencv3

mac10.12.6系統配置clion編寫CMakeLists文件運行opencv3

執行 mes 成功 clu link net imread cnblogs urn

按照mac10.12.6系統使用cmake安裝opencv3.3.0+opencv_contrib-3.3.0下載編譯安裝好了文件以後,裝好clion編譯器,新建C++可執行工程,編寫代碼

opecv3代碼


#include <iostream>
#include <opencv2/opencv.hpp>

using namespace std;
using namespace cv;

int main() {
    Mat srcImage = imread("1.png");
    if (!srcImage.data) {
        std::cout << "Image not loaded";
        return -1;
    }
    imshow("[img]", srcImage);
    waitKey(0);
    return 0;
}

CMakeLists文件


cmake_minimum_required(VERSION 3.12)
project(OpenCVGrad)

set(CMAKE_CXX_STANDARD 11)


#
FIND_PACKAGE(OpenCV REQUIRED)
#

add_executable(OpenCVGrad main.cpp)

#
target_link_libraries(OpenCVGrad ${OpenCV_LIBS})
#

運行成功

參考感謝

  • CLion中配置OpenCV環境問題

mac10.12.6系統配置clion編寫CMakeLists文件運行opencv3