Mac下OpenCV安装与使用

安装

在终端执行:brew install opencv

使用

CMakeLists.txt

cmake_minimum_required(VERSION 3.13)
project(OpencvDemo)

set(CMAKE_CXX_STANDARD 14)

find_package(OpenCV)

include_directories(${OpenCV_INCLUDE_DIRS})

add_executable(OpencvDemo main.cpp)

target_link_libraries(OpencvDemo ${OpenCV_LIBS})

main.cpp

#include 
#include 
using namespace cv;
using namespace std;

int main() {
    #拷贝路径快捷键:cmd + option + c 
    Mat srcImg = imread("/Users/qingxintao/Desktop/7D04E9C6-90CE-49D5-930C-1C949169AD7F.png");
    if (!srcImg.data) {
        cout << "image not loaded";
        return -1;
    }
    imshow("[img]",srcImg);
    waitKey();
    return 0;
}

你可能感兴趣的:(Mac下OpenCV安装与使用)