Installing OpenCV on a MAC

STEP 1 – Install Xcode

  1. Go to – https://developer.apple.com/xcode/
  2. Follow the installation instructions there, should be pretty straight forward to do.

STEP 2 – Install Homebrew

1.        Open the Terminal, by going to: Applications → Utilities → Terminal

2.       Type the following lines. Note do not type the red numbers, they are

simply line

3. Homebrew has now been successfully installed. We can run an update by doing:

brew install python 

STEP 3 – Install the Anaconda Python Package

1.       Go to: https://www.continuum.io/downloads

2.       Select the OSX installer (choose Python 3.5)

3.       Follow the Installation instructions, should be pretty standard, however Continuum has a guide here: https://docs.continuum.io/anaconda/install

4.       Anaconda which includes Python and lots of useful libraries is now installed.

STEP 4 – Install OpenCV 3.0.0

1. Go to terminal window and type the following:

2. Type the following lines:

3. That’s it, OpenCV 3.0.0 would have been successfully installed.

STEP 5 – Launch an Ipython Notebook and test.

1.       Go to terminal window and type the following: jupyter notebook

2.       Open a new ipython notebook. By clicking new located near the top right of the screen (see red 1 below) and then under Notebooks, click on Python 2 (see red 2 below).

3.       When out notebook file loads, type the 3 following lines of code as shown in the image below.

4. If successful, you should see the statement “Packages successfully imported” .

UPDATE:

If the above methods fail which has been happening to a lot of students due to changes in OpenCV, Anaconda etc. Please try the following alternative methods:

  1. From terminal type and run the following.

conda install -c https://conda.binstar.org/menpo opencv

مطالب مرتبط:

Install OpenCV 3 on macOS with Homebrew (the easy way)

Guide to troubleshooting Issues with Mac installs:

Resolving macOS, OpenCV, and Homebrew install errors