J.Treutlein
J.Treutlein

Reputation: 983

Installing OpenCV3 with Homebrew: No head is defined for opencv

I am having trouble installing OpenCV3 with the error I have...

No head is defined for opencv

I have not found any solution to on the internet. I used these websites as references:

https://www.pyimagesearch.com/2016/12/19/install-opencv-3-on-macos-with-homebrew-the-easy-way/

https://www.learnopencv.com/install-opencv3-on-macos/


The exact steps I followed were:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo "# Homebrew" >> ~/.bash_profile
echo "export PATH=/usr/local/bin:$PATH" >> ~/.bash_profile
source ~/.bash_profile

brew install python python3
brew link python
brew link python3

Then I tried to see what versions I had so I ran:

which python2
which python3

Only a file path for python3 existed so I decided to explicitly install python2:

brew install python2

Then it said it was already linked when I tried to link it (not sure if this is relevant to the issue, but it may be):

brew link python2

It returned:

Warning: Already linked: /usr/local/Cellar/python@2/2.7.14_3 To relink: brew unlink python@2 && brew link python@2

Then I checked it was all good with which again and python2 and python3 were now there.

python2 --version   ===> Python 2.7.14
python3 --version   ===> Python 3.6.4

The since the pythons (I think) are all good, I tried installing OpenCV3w with:

brew install opencv3 --with-contrib --with-python3 --HEAD

but the error was

Error: No head is defined for opencv

Do I NEED the head? What's wrong with it anyway?


P.S. Not sure if this is relevant, but

brew info opencv3

gives

opencv: stable 3.4.1 (bottled) Open source computer vision library https://opencv.org/ Not installed From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/opencv.rb ==> Dependencies Build: cmake ✘, pkg-config ✘ Required: eigen ✘, ffmpeg ✘, jpeg ✘, libpng ✘, libtiff ✘, openexr ✘, python ✔, python@2 ✔, numpy ✘, tbb ✘


Thank you so much for any support, MUCH appreciated!

Upvotes: 1

Views: 871

Answers (1)

meduz
meduz

Reputation: 4251

Compiling OpenCV can be hard, and even harderon a MacOS. Homebrew alleviates this often, but the current recipe for opencv is a good start.

However, I had problems with it, the main being that it would compile against python2 and that I have all my toolchain in python3. So I created a new cask to install a dependence on tbb and then one for opencv. You will not that to achieve compilation to the end, I had to remove some dependencies, and in particular that to protobuf.

For convenience, you can clone / download the repository and launch this script script which cleans up things and then runs the install. Any comments are welcome!

Upvotes: 0

Related Questions