2021-05-12 14:32:11
Mac OS X安裝OpenCV並設定到Xcode和Eclipse上
Mac OS X安裝OpenCV並設定到Xcode和Eclipse上
1.安裝OpenCV for MAC:
1).首先下載opencv for mac安裝原始檔,http://opencv.org/downloads.html,解壓縮
2).安裝brew:終端輸入:
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
更新Homebrew,Terminal中輸入:brew selfupdate
3).安裝cmake:brew install cmake
4). 進入存放解壓後的opencv資料夾,新建一個空的資料夾release,進入該資料夾,編譯安裝opencv,使用命令如下:
tar zxvf OpenCV-2.4.3.tar.bz2
cd OpenCV-2.4.3
mkdir release
cd release
cmake -G "Unix Makefiles" ..
make
sudo make install
安裝好的lib檔案存放在“/usr/local/lib”資料夾,h檔案存放在“/usr/local/include”
2.Xcode中使用OpenCV:
1).新增lib檔案:右鍵點選工程名,選擇“Add files to..”,在檔案選擇對話方塊彈出來時輸入“/”,在彈出的路徑框中輸入:/usr/local/lib,全選該資料夾下的全部dylib檔案(新增opencv_core,opencv_highgui, opencv_imgproc, opencv_ml四個就足夠了),新增至工程。
2). 新增lib檔案查詢支援: 點選工程名檔案,進入“Build Settings”索引標籤,在“Library Search Paths”欄中輸入“/usr/local/lib”
3).新增標頭檔案:點選工程名檔案,進入“Build Settings”索引標籤,在“Header Search Paths”欄中輸入:“/usr/local/include /usr/local/include/opencv”
4).對於C++版的OpenCV,會出現下面的錯誤:
Undefined symbols for architecture x86_64
“cv::imshow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cv::_InputArray const&)”, referenced from:
_main in main1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
解決方法為:
Open Build Settings by double-clicking on the project name with the Xcode icon.
In this window, under “Architectures” section, set “Base SDK” to “Current OX S”.
Now scroll down to “Apple LLVM compiler 4.1 – Language” section.
In “C++ Language Dialect”, change it to “Compiler Default”. In “C++ Standard Library”, change it from “libc++ (LLVM …)” to “libstdc++ (GNU C++ …)”
3.Eclipse設定OpenCV:
1).安裝帶有CDT的Eclipse,使用eclipse建立一個Mac C++工程,包含一個cpp檔案
2).右擊工程名, 選擇“Properties”,在屬性設定頁中選擇,點選C/C++ Build, 在下拉選項中選擇 Settings. 在右邊的索引標籤中選擇 Tool Settings
3). 在GCC C++ Compiler選項列表中選擇Includes,在Include paths(-l)中新增安裝好的opencv的標頭檔案存放目錄:/usr/local/include/(注意最後面的/不能少)
4.在MacOS X C++Linker選項列表中選擇Library,在Library search path (-L)中新增安裝好的opencv Lib檔案存放目錄:/usr/local/lib/
5.MacOS X C++Linker選項列表中選擇Library, 在Libraries(-l) 中依次點選“+”號,新增需要使用的Lib檔案(通常情況下,使用前三個):
opencv_core opencv_imgproc opencv_highgui opencv_ml
Mac平台上OpenCV開發環境搭建 http://www.linuxidc.com/Linux/2016-09/135028.htm
Mac OS X安裝OpenCV並設定到Xcode和Eclipse上 http://www.linuxidc.com/Linux/2016-09/135029.htm
--------------------------------------分割線 --------------------------------------
OpenCV官方教學中文版(For Python) PDF http://www.linuxidc.com/Linux/2015-08/121400.htm
Ubuntu Linux下安裝OpenCV2.4.1所需包 http://www.linuxidc.com/Linux/2012-08/68184.htm
Ubuntu 12.04 安裝 OpenCV2.4.2 http://www.linuxidc.com/Linux/2012-09/70158.htm
CentOS下OpenCV無法讀取視訊檔 http://www.linuxidc.com/Linux/2011-07/39295.htm
Ubuntu 12.04下安裝OpenCV 2.4.5總結 http://www.linuxidc.com/Linux/2013-06/86704.htm
Ubuntu 10.04中安裝OpenCv2.1九步曲 http://www.linuxidc.com/Linux/2010-09/28678.htm
基於QT和OpenCV的臉部辨識系統 http://www.linuxidc.com/Linux/2011-11/47806.htm
相關文章