Rider44
Rider44

Reputation: 141

Home-brew install both OpenCV 2.4 and OpenCV3.1 on a Mac?

I have OpenCV3.1 installed with Homebrew on my Mac, but for a new project I need to use OpenCV2.4. I just checked with the following commands:

$brew info opencv3
$brew info opencv

Seems to me that two versions of OpenCV are independent.

So my question is if I can install OpenCV2.4 without causing interference to my OpenCV 3.1? Also like to know if I can use either Python or C++ to call OpenCV if both two versions are installed?

Thanks for your suggestions and comments

Upvotes: 2

Views: 3564

Answers (1)

felix the cat
felix the cat

Reputation: 165

Was asking myself the same question today...

For me the following worked so far: Using homebrew and pyenv (the latter I installed with homebrew), I decided to use python3 with opencv3 and python2.7 with opencv2 (both anaconda-python distributions). To have the python installations as clean as possible, do not use homebrew to install python or packages but pyenv. Also during the opencv installation the --without-numpy is important. The rough steps are:

  1. use pyenv to set the global python
  2. install opencv
  3. use conda to install the python packages
  4. manually link the opencv-python packages to the active python distribution

The commands for opencv2 then look like:

pyenv global anaconda-2.4.0
brew install opencv --with-ffmpeg --with-java --without-numpy
conda install -c "https://conda.binstar.org/menpo opencv"
echo "/usr/local/opt/opencv/lib/python2.7/site-packages" >> "~/.pyenv/versions/anaconda-2.4.0/lib/python2.7/site-packages/homebrew-opencv.pth"

For opencv3 the main difference is in the options when installing the formula:

brew install opencv3 --without-numpy --with-python3 --with-contrib --with-examples --with--ffmpeg --with-java

The rest can be adapted one to one from the opencv2 code. To get the paths right brew info opencv helps.

Upvotes: 2

Related Questions