-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenCV_Installation_Steps.txt
80 lines (47 loc) · 2.89 KB
/
OpenCV_Installation_Steps.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Steps to install OpenCV3.3.0 with Python on RaspberryPi
1. Check for Updates: sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get autoremove
2. Install the Dependencies:
Build tools: sudo apt-get install build-essential cmake pkg-config
GUI: sudo apt-get install libgtk2.0-dev libgtk-3-dev
Media I/O: sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev | (Optional) zlib1g-dev libwebp-dev libpng-dev libopenexr-dev libgdal-dev
Video I/O: sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo libdc1394-22-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev yasm libopencore-amrnb-dev libopencore-amrwb-dev libxine2-dev
Matrix Operations: sudo apt-get install libatlas-base-dev gfortran
Python Header Files: sudo apt-get install python2.7-dev python3-dev
NumPy, SciPy and MatPlotLib: pip3 install numpy scipy matplotlib
Java: sudo apt-get install ant default-jdk
Parallelism and linear algebra libraries: sudo apt-get install libtbb-dev libeigen3-dev
Documentation: sudo apt-get install doxygen sphinx-common texlive-latex-extra
3. Download and Decompress OpenCV:
From the OpenCV official website or Github repository and download the required 3.3.0 version for Linux along with opencv_contrib repository. Then decompress the downloaded files.
wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.3.0.zip
unzip opencv.zip
wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.3.0.zip
unzip opencv_contrib.zip
4. Compile and Install OpenCV:
In your terminal, make sure you are within the OpenCV directory and run the following commands:
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr -D WITH_TBB=ON -D BUILD_TBB=ON -D WITH_OPENGL=ON -D WITH_VTK=ON -D WITH_GDAL=ON -D WITH_XINE=ON -D BUILD_ZLIB=ON -D WITH_V4L=ON -D WITH_GSTREAMER=ON -D WITH_OPENEXR=ON -D WITH_UNICAP=ON -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.3.0/modules -D PYTHON_EXECUTABLE=/usr/bin/python3 -D BUILD_EXAMPLES=ON ..
make -j4
If there are errors while compiling use single core:
make clean
make
Install OpenCV: sudo make install
sudo ldconfig
5. Check Installation:
OpenCV should now be installed in /usr/lib/python3.5/dist-packages/. Verify it using command,
ls /usr/lib/python3.5/dist-packages/
Output: cv2.cpython-35m-arm-linux-gnueabihf.so
Change the filename to cv2.so making it easy for importing it into our code:
cd /usr/lib/python3.5/dist-packages/
sudo mv cv2.cpython-35m-arm-linux-gnueabihf.so cv2.so
6. Test the OpenCV Installation:
Import cv2 in python to test the installation
cd ~/Documents/
python3
>>> import cv2
>>> cv2.__version__
'3.3.0'
>>> exit()
If you are able to see '3.3.0' as output you have successfully installed OpenCV on the RaspberryPi and are ready to start your Image Processing Adventures.