Mac下Opencv(2.4.9)配置Xcode(4.6.1),opencvxcode

來源:互聯網
上載者:User

Mac下Opencv(2.4.9)配置Xcode(4.6.1),opencvxcode
1:安裝homebrew和cmake

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install cmake2:安裝opencvbrew tap homebrew/sciencebrew install opencv3.使用Xcode進行OpenCV項目開發

1.Open Xcode, choose New -> New Project -> Command Line Tool

2.Name it and select C++ for type

3.Click on your project from the left menu. Click the  build settings tab from the top. Filter all. Scroll to  Search Paths. Under  header search paths, for debug and release,set the path to  /usr/local/include. Under  library search paths, set the pathto  $(PROJECT_DIR). Finally, check if  C++ standard library is  libc++(Xcode預設的就是這個 ) or not,if not, change it to this!ps:部分xcode和opencv的版本需要用libstdc++,請自行測試哪個適合自己。4.Click on your project from the left menu.  File->New->New Group, Name the group  OpenCV Frameworks. 5.Select the folder (group) you just labeled,  OpenCV Frameworks in the left menu. Go to  File -> add Files, Type shift + command +G, which will allow you to manually go to a folder. Go to ->  /usr/local/lib6.Select both of these files,  libopencv_core.dyliblibopencv_highgui.dylib,and click  Add. (you may need to add other library files from this folder to run other code.)7.You must include this line of code in the beginning of your main.cpp file: #include <opencv2/opencv.hpp>可以修改main.cpp,代碼如下,運行結果就是顯示一張指定的圖片 #include <opencv2/opencv.hpp>usingnamespace cv;intmain(intargc,char ** argv){      Matimage;     image = imread("/Users/hujiawei/Pictures/others/other_naicha/naicha.jpg",1);     namedWindow("Display Image",WINDOW_AUTOSIZE);     imshow("Display Image",image);     waitKey(0);return0;}







聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.