1. 程式人生 > >Opencv在mac系統的安裝與試用

Opencv在mac系統的安裝與試用

網上 tin pty group name bsp -s setting -h

1.在mac終端內,使用brew安裝opencv3,這時我的opencv被安裝到/usr/local/Cellar/opencv3/3.2.0內。

2.新建xcode 項目,選擇command line tool,在項目目錄內新建一個group,把/usr/local/Cellar/opencv3/3.2.0/lib內的含有libopencv的dylib都添加進去。

3.在build settings 內更改Header Search Paths為/usr/local/Cellar/opencv3/3.2.0/include, Library Search Paths 更為/usr/local/Cellar/opencv3/3.2.0/lib。註意此處不能copy網上僅僅是/usr/local/include 或者/usr/local/lib,要根據你opencv安裝地址而定

4.在main函數中輸入,即可顯示出圖片,註意圖片的路徑要正確,自己定。

#include "opencv2/core.hpp"

#include "opencv2/imgcodecs.hpp"

#include "opencv2/highgui.hpp"

#include <iostream>

#include <string>

using namespace cv;

using namespace std;

int main(int argc, char** argv)

{

String imageName("/Users/mac-jcc/Desktop/opencv-00/jcc.png");

Mat image;

image = imread(imageName, IMREAD_COLOR);

if(image.empty())

{

cout<<"could not open or find the image"<<std::endl;

return -1;

}

namedWindow( "Display window", WINDOW_AUTOSIZE );

imshow( "Display window",image );

waitKey(0);

return 0;

}

Opencv在mac系統的安裝與試用