I have trawled through all of Google's and Stack Overflow's search results in order to install stupid OpenCV on my Mac and all the methods have been completely useless.
I started trying to do this with OS X 10.8 and its XCode version and it didn't work. Now I'm on 10.9 and XCode 5.0.1.
I have tried mainly 2 methods: 1) Downloading the .dmg file from OCV website and doing the CMAKE routine. When I get to the make -j8 step, at around 36% it gives me errors such as:
-make[1]: * [modules/imgproc/CMakeFiles/opencv_perf_imgproc.dir/all] Error 2
-Documents/Libraries/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:480:12: note: expanded from macro 'CV_PERF_TEST_MAIN_INTERNALS' while (++argc >= (--argc,-1)) {VA_ARGS; break;} /this ugly cons... ^ ~~ 1 error generated. make[2]: ** [modules/imgproc/CMakeFiles/opencv_perf_imgproc.dir/perf/perf_main.cpp.o] Error 1
2) Using Homebrew at the end of which, even if I added the python path, when I do 'import cv' it gives me a "no module named cv" error
I tried Macports as well a while ago so I don't remember the steps, but it didn't work.
It goes without saying that I've tried different versions of OCV and all have given me issues at the make step.
Any other solutions?
To install Xcode go to App Store -> Search bar -> Type Xcode -> Click Download. Step 2: Now after the successful installation of Xcode, Next we have to install the command-line tool for Xcode. To install the command-line tool for Xcode, open the terminal and copy-paste the following code into your Terminal.
OpenCV can be installed using pip. The following command is run in the command prompt to install OpenCV. This command will start downloading and installing packages related to the OpenCV library. Once done, the message of successful installation will be displayed.
There is a great tutorial located here. It highlights that the version you are trying to use "is not compatible". I am thinking that you should try installing the version stated in those instructions and see how you go.
The following instructions are taken directly from that link:
INSTALLING CMAKE
First you need to download the .dmg file under Binary Distribution of CMake here. At the time of I installed this, the file name is cmake-2.8.11.2-Darwin64-universal.dmg.
Upon completion of the installation you will be prompted whether to put CMake in /usr/bin, select Yes and finish installation
To ensure that CMake has been successfully installed, type cmake -version in Terminal
INSTALLING OPENCV
First, download the tar file of OpenCV 2.4.3 stable version here and DO NOT use the latest version. I struggled with the installation because I used OpenCV 2.4.6.1 and it's not yet compatible.
Extract the tar file in a folder and go to that folder through the terminal, e.g. cd Downloads/OpenCV-2.4.3
Now, each of the following line is to be executed in Terminal and must be executed successfully (no error)
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make -j8
sudo make install
You are all set to use OpenCV!
Steps for those who prefer to build opencv from source
I prefer to use cmake-gui
instead of entirely doing this from command line, since that gives you more idea about the options available for opencv configuration and bring you in better position if you want to customize opencv build tomorrow ( like enabling java wrapper or OpenCL etc ).
source path
to downloaded opencv directory and build path
to
your choice and click Configure button.
CMAKE_INSTALL_PREFIX
- change opencv install pathBUILD_SHARED_LIBS
- build static or shared library. etc Then click Configure again. If there are still errors, edit the option(s) causing the error and click Configure button. Repeat the edit / Configure cycle until there are no more errors. Once there are no more errors, proceed to step (8).
A minimal sample config of the WITH
tab below. Feel free to play with options. This might cause build problems initially. But your understanding of build, will be better.
make
( in terminal at build folder )make install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With