http://www.codesec.net/view/167680.html
http://www.codesec.net/view/167680.html
Step1: Installing Xcode
Step 2: Setup Homebrew
$ cd ~
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew update
Step 3: Install Python 3S
$ brew install python3
$ brew linkapps
Step4: Edit bash profile
Insert:
# Homebrew
export PATH=/usr/local/bin:$PATH
$ source ~/.bash_profile
Step 4: Confirm that Python 3.4 has been installed:
$ which python3
/usr/bin/local/python
$ python3 --version
Python 3.4.3
Step 5: Setup our Python 3.4 environment
$ pip3 install virtualenv virtualenvwrapper
Insert in bash profile
# Virtualenv/VirtualenvWrapper
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
$ source ~/.bash_profile
Step 6: enter into python virtual environment
$ mkvirtualenv cv3 -p python3
$ workon cv3
$ pip install numpy
Step 7: Install OpenCV prerequisites
$ brew install cmake pkg-config
$ brew install jpeg libpng libtiff openexr
$ brew install eigen tbb
Step 8: Compile OpenCV
$ cd ~
$ git clone https://github.com/Itseez/opencv.git
$ cd opencv
$ git checkout 3.0.0
$ cd ~
$ git clone https://github.com/Itseez/opencv_contrib
$ cd opencv_contrib
$ git checkout 3.0.0
$ cd ~/opencv
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D PYTHON3_PACKAGES_PATH=~/.virtualenvs/cv3/lib/python3.4/site-packages \
-D PYTHON3_LIBRARY=/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/libpython3.4m.dylib \
-D PYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/include/python3.4m \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..
$ make -j4
$ sudo make install
Step 9: Verify the install
$ cd ~/.virtualenvs/cv3/lib/python3.4/site-packages/
$ ls -l cv2.so
-rwxr-xr-x 1 admin _developer 2013028 Jun 19 06:11 cv2.so(cv3)74-80-245-164:~ admin
$ python3
Python 3.4.3 (default, Jun 19 2015, 05:23:16)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.0.0'