Report - Install Raspberry Pi With OpenCV and Demo Facedetect

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

I HC QUC GIA THNH PH H CH MINH

TRNG I HC CNG NGH THNG TIN

N MN HC 2
HNG DN CI T RASPBERRY PI V OPENCV 2.4.8
VI DEMO NHN DNG KHUN MT
THNG QUA RASPBERRY CAMERA MODULE

Gio vin hng dn:


Ks. Cao Vn Hng
Ths. Th Lun
Sinh vin :
Nguyn c Trung- 1052035
Trn Thanh Lim - 10520364

Ci t Raspberry v Demo OpenCV


Mc Lc:

I.

Ci t Raspbian vo th nh ( SD card):.............................................................................................. 3
1)

Chun b phn mm: ......................................................................................................................... 3

2)

Ci t ln SD card: ........................................................................................................................... 4

II.

Ci t ln Raspberry Pi: ....................................................................................................................... 5

III.

Config c bn cho Raspberry Pi: ....................................................................................................... 5

1)

Config Network : ............................................................................................................................... 5

2)

iu khin Raspberry Pi t xa qua 1 my khc:................................................................................ 6

IV.

Ci t OpenCV ln Raspberry Pi: ..................................................................................................... 7

1)

Ci t cc gi cn thit h tr OpenCV: .......................................................................................... 7

2)

Download v ci t OpenCV 2.4.8: ............................................................................................... 11

3)

Chy code mu OpenCV:................................................................................................................. 17

2|Page

Ci t Raspberry v Demo OpenCV

I.

Ci t Raspbian vo th nh ( SD card):
1) Chun b phn mm:
-

Raspbian OS: Download ti http://www.raspberrypi.org/downloads/

SD formatter : Download ti https://www.sdcard.org/downloads/formatter_4/

3|Page

Ci t Raspberry v Demo OpenCV

Win32diskimager: Download ti http://sourceforge.net/projects/win32diskimager/

2) Ci t ln SD card:
-

Dng SD formatter nh dng li th nh :


Gn th SD vo my tnh.
Khi ng SD Formatter, chn ng th phn Drive.
Click Option, mc Format Size Adjustment chn ON.
Sau cng, click Format.
S dng Win32diskimager np image Raspbian OS vo th:
Trong Image File chn image Raspbian va ti v.
Chn a ca th SD trong Device.
4|Page

Ci t Raspberry v Demo OpenCV


Bm Write bt u ghi.

II.

Ci t ln Raspberry Pi:
-

III.

Sau khi np h iu hnh Raspbian vo th nh, cm th, cm cp HDMI, bn phm,


chut v dy mng vo Raspberry Pi.
Cm ngun vo, ta s thy mn hnh khi ng ca Raspberry Pi vo thng Raspiconfig.

Chn dng th 3- Enable boot to Desktop/Scratch. Sau thot ra chn Finish


khi ng li Raspberry Pi v hon tt qu trnh ci t.
Khi Raspi khi ng xong, ta g username l pi, password l raspberry, sau g
startx vo mn hnh giao din RasPi.

Config c bn cho Raspberry Pi:


1) Config Network :
-

Ta vo Terminal trn desktop. G lnh: sudo nano /etc/network/interfaces


chnh thng s ci t cho mng dy, y trng hp ta t ip tnh laptop c
th kt ni vo bng giao thc vnc.

5|Page

Ci t Raspberry v Demo OpenCV

y ta t IP ca Raspi l 192.168.0.210, IP mng l 192.168.0.1.


Note: Nu mun a ch IP t cp pht th ta ch cn sa li dng th 3 thnh
iface eth0 inet dhcp v xa cc dng th 4 tr i.
lu li bm t hp phm Ctrl + O ==> Enter ==> Ctrl + X.
Sau ta g lnh sudo reboot khi ng li card mng.

2) iu khin Raspberry Pi t xa qua 1 my khc:


-

Ti terminal g:
sudo raspi-config : vo mn hnh config raspi
Chn mc Advance Options SSH Enable ri OK.

Ci t SSH client trn my tnh Windows. Download phn mm PuTTY ti


http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html .
6|Page

Ci t Raspberry v Demo OpenCV


-

Trn giao din PuTTY ta nhp a ch 192.168.0.210 ca Raspi vo Hostname ri


bm Open.

Ci t VNCServer ln Raspi. Ti terminal ta g:


sudo apt-get install tightvncserver
tightvncserver
vncserver:1 geometry 1024x768 depth 24
Ci t VNCViewer ti my client mun truy cp vo Raspi. Download ti
http://www.realvnc.com/download/viewer/ . Chy vncviewer v in
192.168.0.210:5901 vo VNC Server. Sau bm Connect l ta hon ton s
dng c Raspi thng qua iu khin t xa.

IV.

Ci t OpenCV ln Raspberry Pi:


1) Ci t cc gi cn thit h tr OpenCV:
-

Config ssh v camera:


sudo raspi-config

7|Page

Ci t Raspberry v Demo OpenCV

ssh-->enable : bt ssh.

camera-->enable : bt camera.
8|Page

Ci t Raspberry v Demo OpenCV

// cp nht driver mi nht.


sudo apt-get update

sudo apt-get upgrade

9|Page

Ci t Raspberry v Demo OpenCV

// kim tra camera.


lsusb
sudo apt-get install guvcview

guvcview : bt th camera.
// ci t synaptic.
sudo apt-get install synaptic

// ci t python scipy stack.

sudo apt-get install python-numpy python-scipy python-matplotlib pythonpandas python-sympy python-nose

10 | P a g e

Ci t Raspberry v Demo OpenCV

2) Download v ci t OpenCV 2.4.8:


// download opencv bn 2.4.8
wget
http://sourceforge.net/projects/opencvlibrary/files/opencvunix/2.4.8/opencv-2.4.8.zip/download

// ci t mi trng pht trin cho opencv.

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


11 | P a g e

Ci t Raspberry v Demo OpenCV

sudo apt-get install default-jdk ant

sudo apt-get install libgtkglext1-dev

sudo apt-get install bison

sudo apt-get install qt4-dev-tools libqt4-dev libqt4-core libqt4-gui

sudo apt-get install v4l-utils


12 | P a g e

Ci t Raspberry v Demo OpenCV

sudo apt-get install qtcreator ( C th ci hoc khng).

// ci t opencv.
unzip opencv-2.4.8.zip
cd opencv-2.4.8
mkdir build
cd build

cmake
D
CMAKE_BUILD_TYPE=RELAESE
D
INSTALL_C_EXAMPLES=ON
D
INSTALL_PYTHON_EXAMPLES=ON D BUILD_EXAMPLES=ON
D WITH_QT=ON D CMAKE_INSTALL_PREFIX=/usr/local D
WITH_OPENGL=ON
D
WITH_V4L=ON
D
BUILD_NEW_PYTHON_SUPPORT=ON D WITH_TBB=ON..

13 | P a g e

Ci t Raspberry v Demo OpenCV


Make

sudo make install

14 | P a g e

Ci t Raspberry v Demo OpenCV

// sa cc file config link th vin.


sudo nano /etc/ld.so.conf.d/opencv.conf

thm vo dng:

/usr/local/lib

15 | P a g e

Ci t Raspberry v Demo OpenCV

sudo ldconfig
sudo nano /etc/bash.bashrc

thm vo cui:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH

16 | P a g e

Ci t Raspberry v Demo OpenCV


Lu cc file li.

3) Chy code mu OpenCV:


// chy code mu ca opencv.
cd /opencv-2.4.8/samples/c
chmod +x build_all.sh
./build_all.sh
// chy facedetect.
./facedetect

// chy code mu python.


cd /opencv-2.4.8/samples/python2
./facedetect.py

17 | P a g e

Ci t Raspberry v Demo OpenCV

18 | P a g e

You might also like