按照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})
#