Friday, August 26, 2016

My Pi 3 Install Log (5): OpenCV (part 1) on Raspberry Jessie (Lite)


$ apt-get upgrade

########################
## now play with OpenCV ##
########################


Title: opencv w/ python bindings


## step 1 expand file system (no need)


## step 2 dependencies


# dev tools
(no need, already have) $ sudo apt-get install build-essential cmake pkg-config


# image I/O packages
$ sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev


# video I/O packages
$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
$ sudo apt-get install libxvidcore-dev libx264-dev


# Opencv has a sub-module highgui, for display image and basic GUI, has dependency on gtk2.0 (crap! Download 20.6MB->60.x)
$ sudo apt-get install libgtk2.0-dev


# matrix operations needs a few optimization libraries, which are important on resource constrained devices like Pi. (dl 9MB->45MB)
$ sudo apt-get install libatlas-base-dev gfortran


# python 2.7 and 3 header files for opencv w/ python bindings(dl 44->70MB)
$ sudo apt-get install python2.7-dev python3-dev


## step 3: opencv source 3.1 (first 3.x stable version) 76MB


# main source
$ cd ~
$ wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.1.0.zip
$ unzip opencv.zip


# need features such as SIFT and SURF, so opencv_contrib (52.6MB)
$ wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.1.0.zip
$ unzip opencv_contrib.zip


# install ‘pip’, a Python package manager
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py


## step 4: python


# virtualenv and virtualenvwrapper
$ sudo pip install virtualenv virtualenvwrapper
$ sudo rm -rf ~/.cache/pip


# ‘df -h’ now 3.8G (27%) used


# append to ~/.profile
# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh


# now take effect
$ source ~/.profile


## next to do creating your python virtual environment

# 2.7 or 3  ??

# I did:
$ mkvirtualenv cv -p python2

-- to be continue .. --

Labels: , , ,

0 Comments:

Post a Comment

<< Home