-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopencv_setup.txt
55 lines (37 loc) · 1.88 KB
/
opencv_setup.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Author: Kevin Wang
Last Updated: 5/12/16
Instructions for setting up environment — works on Kevin’s Macbook Pro, but have had issues when trying to install on Mac Mini.
1. Install python
2. Install pip
pip install virtualenv
3. Make the virtual env (optional)
mkvirtualenv [name]
workon [name]
4. Install the necessary libraries from pip
pip install pillow numpy scipy matplotlib
5. Download opencv3.1.0.zip http://opencv.org/downloads.html, extract to a folder,
5.1 — fix the webcam issue with opencv3.1.0 waitKey():
see https://github.com/Itseez/opencv/pull/6051/commits/a2bda999211e8be9fbc5d40038fdfc9399de31fc
5.2 Download from https://github.com/Itseez/opencv_contrib to get the extra modules, placing opencv_contrib in the same directory as the one containing opencv3.1.0
5.3 Building:
Then to install it:
cd opencv-3.1.0 or wherever that folder is
mkdir build
cd build
cmake -D MAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=$VIRTUAL_ENV/ -D PYTHON_EXECUTABLE=$VIRTUAL_ENV/bin/python -D PYTHON_PACKAGES_PATH=$VIRTUAL_ENV/lib/python2.7/site-packages -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..
6. Install opencv
make -j4
make install
6.2 Found the fix for lib installation for opencv, need to add opencv-3.1.0/build/lib to your PYTHONPATH
(Originally, needed the dir "lib" from the build in whatever directory you are working on in order for it to work and copy it into the working code directory...)
go to virtualenv/bin/activate
add after export VIRTUAL_ENV
export OLD_PYTHONPATH="$PYTHONPATH"
export PYTHONPATH="${PYTHONPATH}:YOUR_PATH_TO_THE_opencv-3.1.0/build/lib"
and add to the deactivate() loop
export PYTHONPATH="$OLD_PYTHONPATH"
7. Verify
python -c "import cv2; print cv2.__version__"
import cv2
detector = cv2.AKAZE_create()
cv2.face.createEigenFaceRecognizer() # verifies the extra modules are working