doing some machine learning and want to install openCV the right way to be used with python, follow here!
Install home-brew for mac.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
python2.7 usually comes installed in macOS, if not
brew install python
add openCV to the search using the tap argument in home brew
brew tap homebrew/science
install openCV with the obvious command for installing opencv-2.4.12_2
brew install opencv
but we want to install opencv 3.0 which means, we have to compile from source.
hit the terminal with the following,
cd ~/Documents/dev
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout 3.0.0
cd~/opencv
mkdir build
cd build
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.10/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=~/opencv/modules ..
now make with the number of jobs, i like to put the number of cores in your PC. when you don’t know, hit this to find out in a macOS sysctl -n hw.ncpu
make -j4
make install
when permissions are a problem, do the obvious
sudo make install
to check if it installed on your python path, hit the python shell
python
>>> import cv2
>>> cv2.__version__
'3.0.0'
if you want this to be installed in your python path of your virtual environment, you need to create a symbolic link of the installed openCV library in your brew installed python into your site packages of the virtual environment venv
next step of the project is to write the logic for converting the image/video feed as inputs for the machine learning algorithm.