Install OpenCV with Python2 in OSX-installs Python2 based OPENCV on OSX

Source: Internet
Author: User
Tags install homebrew virtualenv

Basically follow the http://www.pyimagesearch.com/2015/06/15/install-opencv-3-0-and-python-2-7-on-osx/installation, in addition to changing some of your own directories.

1. Install Xcode

2. Install Homebrew-Add OSX to some packages

$ cd ~"$ (curl-fssl https://raw.githubusercontent.com/Homebrew/install/master/install) "
Update

3. Install the Python2. It is recommended to reinstall, not to use the system comes with the

Install python

Open ~/. Bash_profile, adding environment variables

Export Path=/usr/local/bin: $PATH

Reload after Save

$ source ~/.bash_profile

Now it's time to check if the Python on the newly installed

which python/usr/local/bin/python

New python should be in /usr/local/bin/python, and if displayed /usr/bin/ Python is or is a system that comes with Python

4. Installing virtualenv

Install virtualenv virtualenvwrapper

and edit ~/. Bash_profile file, put

Source/usr/local/bin/virtualenvwrapper. SH

and reload

$ source ~/.bash_profile

Virtualenv to create CV

$ mkvirtualenv CV

5. The following operations can be operated in virtualenv

Install NumPy

6. The brew operation can also be virtualenv outside

Install Pkg-config
install jpeg libpng libtiff OPENEXR
Install Eigen TBB

7. Start the installation of OpenCV

$ cd ~$ git clone https://github.com/itseez/opencv.git3.0. 0

And some packages you'll need.

$ cd ~$ git clone https://github.com/itseez/opencv_contrib3.0. 0

Two must be the same version.

8. CMake

$ cd ~/mkdir  build$ CD Build

The original text is:

$ cmake-d cmake_build_type=release-d cmake_install_prefix=/usr/local     -D python2_packages_path=~/. Virtualenvs/cv/lib/python2. 7/site-packages     -D python2_library=/usr/local/cellar/python/2.7.  Ten/frameworks/python.framework/versions/2.7/bin     -D python2_include_dir=/usr/local/ frameworks/python.framework/Headers     -D install_c_examples=on-d install_python_examples= on      -Dbuild_examples=     on-D opencv_extra_modules_path=~/opencv_contrib/modules.

And I actually changed a lot of directories. My own is:

$ cmake-d cmake_build_type=release-d cmake_install_prefix=/usr/local-d PYTHON2_PACKAGES_PATH=~/WORK/VIRTUALENVS/CV /lib/python2. 7/site-packages-d python2_library=/usr/local/cellar/python/2.7. /frameworks/python.framework/versions/2.7/bin-d python2_include_dir=/usr/local/frameworks/ python.framework/headers-d install_c_examples=on-d install_python_examples=on-d build_examples=on-d OPENCV_EXTRA_ Modules_path=~/softwares/opencv_contrib/modules.

Observe the output and confirm that all is done. And then

 make-j4

(The CPU is running at high speed ...) 4 refers to the CPU is available to the kernel)

Install OpenCV with Python2 in OSX-installs Python2 based OPENCV on OSX

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.