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
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,
git clone https://github.com/opencv/opencv.git
git checkout 3.0.0
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
when permissions are a problem, do the obvious
sudo make install
to check if it installed on your python path, hit the python shell
>>> import cv2
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.