Module3. Unsuspected person detection - GachonCapstoneDesign/DoorWatcher GitHub Wiki
We use Raspberry Pi camera to do image processing and detect suspicious people through our algorithms.
First, to use OpenCV in raspberry pi, the following process is required.
You need to install the following OpenCV in the raspberry pi. First update the basic packages installed in the raspberry pi.
sudo apt-get update
sudo apt-get upgrade The list below is a required package when using OpenCV.
build-essential
cmake
pkg-config
libjpeg-dev
libtiff5-dev
libjasper-dev
libpng12-dev
libavcodec-dev
libavformat-dev
libswscale-dev
libv4l-dev
libxvidcore-dev
libx264-dev
libgtk2.0-dev
libatlas-base-dev
gfortran
python2.7-dev
python3-dev
sudo apt-get install {Package name}
Now download the OpenCV and unzip it.
wget -O openCV2.4.9.zip http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv 2.4.9.zip/download
unzip openCV-2.4.9.zip
Now go to the folder where you unzipped and go through the following process.
cd openCV-2.4.9
cmake .
make -j4
'cmake' checks the packages installed on your system and automatically creates a Makefile for your build. Then builds through make -j4. Usually oepncv build time is very long. Once the build is finished, the installation will complete the installation of opencv.
sudo make install
When the installation is complete, type pkg-config --modversion opencv to verify the version.
This code is now on the github.
- Github. Click the hyperlink to go to the github repository.
When you run 'doorwatcher.py' in Python, it will take the first picture taken by the camera. When the image frame changes on the screen, it starts counting itself (set to count up to 100). When the motion disappears from the screen, the count is reset.
The following images are images that are operated using a notebook camera, not a Raspberry pi camera module.
Youtube
๋ผ์ฆ๋ฒ ๋ฆฌํ ์นด๋ฉ๋ผ๋ฅผ ์ด์ฉํด์ ์ด๋ฏธ์ง ํ๋ก์ธ์ฑ์ ํ๊ณ ์ ํฌ์ ์๊ณ ๋ฆฌ์ฆ์ ํตํ์ฌ ์์ํ ์ฌ๋์ ๊ฐ์งํฉ๋๋ค.
๋จผ์ ๋ผ์ฆ๋ฒ ๋ฆฌํ์ด์์ OpenCV ๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด์ ๋ค์๊ณผ ๊ฐ์ ๊ณผ์ ์ด ํ์ํฉ๋๋ค.
๋ผ์ฆ๋ฒ ๋ฆฌํ์ด์ ๋ค์ OpenCV๋ฅผ ์ค์นํด์ผํฉ๋๋ค.
๋จผ์ ๋ผ์ฆ๋ฒ ๋ฆฌํ์ด์ ์ค์น๋ ๊ธฐ๋ณธ ํจํค์ง๋ค์ ์
๋ฐ์ดํธ ํฉ๋๋ค.
sudo apt-get update
sudo apt-get upgrade ์๋ ๋ชฉ๋ก์ OpenCV๋ฅผ ์ฌ์ฉํ ๋ ์๊ตฌ๋๋ ํจํค์ง ์ ๋๋ค.
build-essential
cmake
pkg-config
libjpeg-dev
libtiff5-dev
libjasper-dev
libpng12-dev
libavcodec-dev
libavformat-dev
libswscale-dev
libv4l-dev
libxvidcore-dev
libx264-dev
libgtk2.0-dev
libatlas-base-dev
gfortran
python2.7-dev
python3-dev
sudo apt-get install {ํจํค์ง๋ช
}์ผ๋ก ์ค์นํฉ๋๋ค.
์ด์ OpenCV๋ฅผ ๋ค์ด๋ฐ๊ณ ์์ง์ ํด์ ํฉ๋๋ค.
wget -O openCV2.4.9.zip http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv 2.4.9.zip/download
unzip openCV-2.4.9.zip
๋ง์ฝ unzipํจํค์ง๊ฐ ์๋ค๋ฉด sudo apt-get install unzip ๋ฅผ ํตํด ์ค์นํฉ๋๋ค.
์ด์ ์์ถ์ ํด์ ํ ํด๋๋ก ๋ค์ด๊ฐ์ ๋ค์๊ณผ ๊ฐ์ ๊ณผ์ ์ ๊ฑฐ์นฉ๋๋ค.
cd openCV-2.4.9
cmake .
make -j4
cmake๊ฐ ์์คํ
์ ์ค์น๋ ํจํค์ง๋ค์ ํ์ธํ์ฌ ๋น๋๋ฅผ ์ํ Makefile์ ์๋์ผ๋ก ์์ฑํฉ๋๋ค.
๊ทธ๋ค์ make -j4๋ฅผ ํตํด์ ๋น๋๋ฅผ ์ํํฉ๋๋ค.
๋ณดํต oepncv ๋น๋์๊ฐ์ ๋งค์ฐ ์ค๋ ๊ฑธ๋ฆฝ๋๋ค.
๋น๋๊ฐ ๋ง๋ฌด๋ฆฌ๋๋ฉด ์ด์ ์ค์น๋ฅผ ํ๋ฉด opencv์ ์ค์น๊ฐ ๋๋ฉ๋๋ค.
sudo make install
์ค์น๊ฐ ์๋ฃ๋๋ฉด ๋ฒ์ ํ์ธ์ ์ํด์ pkg-config --modversion opencv ์ ์
๋ ฅํฉ๋๋ค.
์ด ์ฝ๋๋ ํ์ฌ ๊นํ๋ธ์ ์ฌ๋ ค๋จ์ต๋๋ค.
- Github. ํ์ดํผ๋งํฌ๋ฅผ ํด๋ฆญํ์๋ฉด ๊นํ๋ธ ํ์ด์ง๋ก ์ด๋ํฉ๋๋ค.
ํ์ด์ฌ์์ doorwatcher.py๋ฅผ ์คํ์ํค๋ฉด ์นด๋ฉ๋ผ๊ฐ ์ฒ์ ์ฐ์ ํ๋ฉด์ ๊ธฐ์ค์ผ๋ก ์ก์ต๋๋ค. ํ๋ฉด์์ ์ด๋ฏธ์ง ํ๋ ์์ด ๋ณ๊ฒฝ๋๊ฒ ๋๋ฉด ์์ฒด์ ์ผ๋ก ์นด์ดํธ๋ฅผ ์ธ๊ธฐ ์์ํฉ๋๋ค (์ต๋ 100๊น์ง ์นด์ดํธํ๊ฒ ์ค์ ํ์ต๋๋ค.) ํ๋ฉด์์ ์์ง์์ด ์์ด์ง๋ฉด ์นด์ดํธ๋ฅผ ์ด๊ธฐํํฉ๋๋ค.
๋ค์์์์ ๋ผ์ฆ๋ฒ ๋ฆฌํ์ด ์นด๋ฉ๋ผ ๋ชจ๋์ด ์๋ ๋ ธํธ๋ถ ์นด๋ฉ๋ผ๋ฅผ ์ด์ฉํด์ ๋์ํ๋ ์์์ ๋๋ค.
Youtube

