1. 去 http://opencv.org 下载最新版OpenCV for Linux/Mac源文件，目前版本是2.4.3。下载后解压。
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
sudo make install
注：如果cmake出现错误，请到苹果开发者网站那里下载Command Line Tools安装。（关键）
1. 打开一个终端，cd ~
2. vim .profile
3. 添加export PYTHONPATH=/usr/local/lib/python2.7/site-packages/，其中python2.7根据个人python版本而定。
4. source .profile
I got this working with OpenCV 2.4.10 and GCC 4.9.2. I also had to make the following additional changes to thein the root OpenCV directory:
OCV_OPTION(WITH_OPENEXR “Include ILM support via OpenEXR” OFF)
OCV_OPTION(WITH_OPENMP “Include OpenMP support” ON)
OCV_OPTION(BUILD_OPENEXR “Build openexr from source” OFF )
I originally was running into errors with “Undefined symbols for architecture x86_64 cv::imshow, cv::imread, cv::imwrite, etc,” because Homebrew installed a clang OpenCV whereas my project was using GCC. One solution would be to rebuild everything with clang but that was not appealing in my case because I wanted OpenMP support. So I instead used your solution to build a GCC version of OpenCV.