Hướng dẫn cài OpenCV 3 + Python cho Raspberry Pi 3

Bước 1 :
Mở rộng không gian thẻ nhớ cho file hệ thống ( Lưu ý thẻ nhớ SD 8GB không đủ dung lượng để cài khuyến cáo sử dụng thẻ nhớ 32GB)
- Gõ lệnh :
"sudo raspi-config "
-> chọn “Advanced Options”
-> chọn “Expand filesystem”

sau đó khởi động lại raspberry pi của bạn.
Bước 2 :
Cài đặt các thư viện cần thiết
-cập nhật các gói cài đặt cho rasperry : gõ lệnh
" sudo apt-get update && sudo apt-get upgrade "
- Cài một số công cụ lập trình bao gồm CMake gõ lệnh
" sudo apt-get install build-essential cmake pkg-config "
-Cài đặt thư viện hỗ trợ các định dạng ảnh , gõ lệnh
" sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev "
và thư viện video gõ lệnh
"sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev "
và thư viện GTK gõ lệnh :
"sudo apt-get install libgtk2.0-dev libgtk-3-dev"
và lệnh :
"sudo apt-get install libatlas-base-dev gfortran"
cài đặt python 2.7 và 3.0
"sudo apt-get install python2.7-dev python3-dev"

Bước 3 :
Cài đặt OPenCV
" cd ~
wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.3.0.zip
unzip opencv.zip"
cài full bộ cài đặt
"wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.3.0.zip
unzip opencv_contrib.zip"
Bước 4 :
Cài đặt Python 2.7 hoặc 3.0
cài goí quản lý Python  gõ lệnh:
"wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
sudo python3 get-pip.py"
Caì đặt môi trường virtualenv virtualenvwrapper
"sudo pip install virtualenv virtualenvwrapper
udo rm -rf ~/.cache/pip"
cần update profile
"# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh"
Tắt terminal và bật 1 terminal mới gõ lênh :
"source ~/.profile"
Tạo môi trường Python ảo
"mkvirtualenv cv -p python2"
hoặc
"mkvirtualenv cv -p python3"
kiểm tra môi trường CV , khi taoj thành công sẽ có từ (cv) trước câu lệnh :
"source ~/.profile
workon cv"
Cài đặt Numpy :
"pip install numpy"
Bước 5 :
Hoàn thiện cài đặt OPenCV
vào lại CV :










No comments:

Related Posts Plugin for WordPress, Blogger...

Cùng tôi học Điện Tử ..(http://ilovec.tk)..