树莓派安装opencv
1. 利用工具SDFormatter将内存卡格式化
选项设置选择擦除格式化,然后点击格式化
2. 烧写系统
准备后缀为img的文件
将这个zip文件解压得到img的镜像文件
使用软件
将img文件写入sd卡
点击Write将文件写入,大概需要5分钟
3. 将烧写好的sd卡直接插入树莓派板子,上电运行,第一次运行不需要密码,但要连接屏幕,因为第一次运行没有开启ssh服务,无法使用远程登陆
4. 默认用户和密码
用户:pi 密码:raspberry
修改密码 passwd
启动root用户
5. 修改配置文件,允许root用户远程登陆(这样可以免去以后频繁移动文件权限不够的问题)
安装vim 输入:apt-get install vim
输入vim /etc/ssh/sshd_config
开启ssh服务
输入 service ssh start
Chkconfig ssh on #设置自启
二.Opencv的安装
网址https://github.com/Tes3awy/OpenCV-3.2.0-Compiling-on-Raspberry-Pi
I assume you have downloaded Raspbian and installed it on your Pi. Also I assume your RPi is running and functioning perfectly.
Make sure you have extended your disk before performing any step from below.
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo rpi-update (can be skipped, but recommended) (don't do it if you will use the RPI cam as recommended by official RPI Website)
$ sudo reboot now
$ sudo apt-get install build-essential cmake pkg-config
$ sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
$ sudo apt-get install libgtk2.0-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev libv4l-0 libv4l-dev
$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
$ sudo apt-get install libxvidcore-dev libx264-dev
$ sudo apt-get install libatlas-base-dev gfortran
$ sudo apt-get install python-numpy python-scipy python-matplotlib
$ sudo apt-get install default-jdk ant
$ sudo apt-get install libgtkglext1-dev
$ sudo apt-get install v4l-utils
install pip
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py
$ sudo apt-get install python2.7-dev
$ sudo pip install numpy
Download OpenCV 3.2.0 and unpack it
$ cd ~
$ wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.2.0.zip
$ unzip opencv.zip
Contrib Libraries (Non-free Modules)
$ wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.2.0.zip
$ unzip opencv_contrib.zip
preparing the build
$ cd ~/opencv-3.2.0/
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.2.0/modules \
-D BUILD_EXAMPLES=ON \
-D ENABLE_NEON=ON ..
takes about 3.5 to 4 hours
$ sudo make -j3 (I prefer -j3, because it doesn't use all the cores so it keeps the RasPi cool enough)
# If any errors occurs and the process fails to continue, execute
$ sudo make clean
# Sometimes using multicores can cause problems, so if you face any problems just execute $ sudo make , but keep in mind that it will take much longer so be patient as much as you can and grab your cup of tea.
installing the build prepared in step 11
$ sudo make install
$ sudo ldconfig
$ sudo nano /etc/ld.so.conf.d/opencv.conf
opencv.conf will be blank, add the following line, then save and exit nano:
/usr/local/lib # enter this in opencv.conf, NOT at the command line
(leave a blank line at the end of opencv.conf)
save opencv.conf by pressing ctrl+o get back again to the command line by pressing ctrl+x
$ sudo ldconfig
$ sudo nano /etc/bash.bashrc
add the following lines at the bottom of bash.bashrc
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
(leave a blank line at the end of bash.bashrc) save bash.bashrc changes (ctrl+o), then back at the command line (ctrl+x),
#Step 15: Reboot
$ sudo shutdown -r now
#Step 16 Last Step: verifying the installation
Open Python 2 IDLE on RasPi Type the following lines in the python shell:
>>> import cv2
>>> print cv2.__version__
the following line should appear then:
'3.2.0'
TODO
· Connect to RPi without internet connection.
资料下载地址网盘链接 链接:https://pan.baidu.com/s/1QJePM_wGY8-KYvcdR-0ePA 密码:lt68
里面包含opencv的源码及扩展模块,以及详细安装方法的word文档