วันศุกร์ที่ 10 สิงหาคม พ.ศ. 2561

Install OpenCV on Raspberry Pi





Install openCV on Raspberry Pi

In this blog post I demonstrated how to install OpenCV 3 with Python 2.7 and Python 3 on Raspberry pi 3B.

What is OpenCV?
OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. 
https://opencv.org/about.html


Hardware

  • Raspberry Pi 3B Board with SD card and accessories.

Software and Library

  • Raspbien Stretch OS
  • OpenCV 3.3.0



Install OpenCV on Raspberry Pi

Update First.

sudo apt-get update sudo apt-get upgrade sudo rpi-update


Cmake (builder and compiler)

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


dependencies  Image และ Video IO

sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev sudo apt-get install libxvidcore-dev libx264-dev

HiGUI 
sudo apt-get install libgtk2.0-dev libgtk-3-dev
sudo apt-get install libatlas-base-dev gfortran


Python Dev
sudo apt-get install python2.7-dev python3-dev



OpenCV source code
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

Build
cd opencv-3.3.0
mkdir build cd build cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D OPENCV_EXTRA_MODULES_PATH=/home/pi/opencv_contrib-3.3.0/modules \ -D BUILD_EXAMPLES=ON \ -D WITH_OPENGL=ON \ -D WITH_V4L=ON ..


Change Some config

sudo /etc/init.d/dphys-swapfile stop
sudo nano /etc/dphys-swapfile 

set CONF_SWAPSIZE 100 (100 MB) to  1024 (1 GB)
then reboot



login again 

sudo /etc/init.d/dphys-swapfile start


MAKE  ( it take 2 hours )
make -j4



sudo make install sudo ldconfig




Test Import OpenCV in python code

python
import cv2
cv2.__version__




Raspberry pi OpenCV Application

Raspberry Pi Car Detection with OpenCV

http://raspberrypi4u.blogspot.com/2018/06/raspberry-pi-car-detection-with-opencv.html














Raspberry Pi Face Detection with OpenCV

http://raspberrypi4u.blogspot.com/2018/06/raspberry-pi-face-detection-opencv.html



2 ความคิดเห็น:

  1. I was searching for this allover the internet since past few hours, and this article turned out to be very considerable for me to end my search. Thank you for making this important piece of knowledge available to us.
    Web Design Agency | Website Redesign Company

    ตอบลบ