安裝 OPENCV 紀錄

網站教人安裝 opencv 這個網頁 Install OpenCV and Python on your Raspberry Pi 2 and B+,先安裝 Raspbian 最新版在樹莓派 2 Model B 上執行,我用 ssh 登入樹莓派去執行。

登入後執行

sudo apt-get update

pi@raspberrypi: ~_148

sudo  apt-get upgrade

pi@raspberrypi: ~_149

sudo rpi-update

pi@raspberrypi: ~_150

正常完成後重開機 sudo reboot

pi@raspberrypi: ~_151

sudo apt-get install build-essential cmake pkg-config

pi@raspberrypi: ~_152

sudo apt-get install libjpeg8-dev libtiff4-dev libjasper-dev libpng12-dev

pi@raspberrypi: ~_153

sudo apt-get install libgtk2.0-dev

pi@raspberrypi: ~_154

sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev

pi@raspberrypi: ~_155

sudo apt-get install libatlas-base-dev gfortran

pi@raspberrypi: ~_156

wget https://bootstrap.pypa.io/get-pip.py

pi@raspberrypi: ~_157

sudo python get-pip.py

pi@raspberrypi: ~_158

sudo pip install virtualenv virtualenvwrapper

pi@raspberrypi: ~_159

update your ~/.profile

pi@raspberrypi: ~_160

pi@raspberrypi: ~_161

source ~/.profile

mkvirtualenv cv

pi@raspberrypi: ~_163

 

sudo apt-get install python2.7-dev

pi@raspberrypi: ~_164

pip install numpy

pi@raspberrypi: ~_165

wget -O opencv-2.4.10.zip http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.10/opencv-2.4.10.zip/download

pi@raspberrypi: ~_166

unzip opencv-2.4.10.zip

pi@raspberrypi: ~_167

cd opencv-2.4.10

mkdir build

cd build

pi@raspberrypi: ~-opencv-2.4.10-build_168

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON  -D BUILD_EXAMPLES=ON ..

pi@raspberrypi: ~-opencv-2.4.10-build_169

make

pi@raspberrypi: ~-opencv-2.4.10-build_170

sudo make install

sudo ldconfig

pi@raspberrypi: ~-opencv-2.4.10-build_171

cd ~/.virtualenvs/cv/lib/python2.7/site-packages/

ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so

ln -s /usr/local/lib/python2.7/site-packages/cv.py cv.py

pi@raspberrypi: ~-.virtualenvs-cv-lib-python2.7-site-packages_172

workon cv

python

pi@raspberrypi: ~-.virtualenvs-cv-lib-python2.7-site-packages_173

每一步驟的結果都正常