安装OpenCV 3 on Raspbian Jessie

环境:

  • 硬件:树莓派三代B型, 5MP Camera Board Module
  • 软件:Raspbian,Opencv
  • 安装依赖

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

  • 安装完成后重启系统

    $ sudo reboot

  • 安装Opencv开发工具

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

  • 安装Opencv图像库等依赖

    $ sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev

  • 安装Opencv加载视频图像库等依赖

    $ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev   $ sudo apt-get install libxvidcore-dev libx264-dev

  • 安装GTK开发库

    $ sudo apt-get install libgtk2.0-dev

  • 安装Opencv附加依赖

    $ sudo apt-get install libatlas-base-dev gfortran

  • 安装python2.7

    $ sudo apt-get install python2.7-dev

  • 下载解压Opencv3.0.0版本

    $ cd ~   $ wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.0.0.zip   $ unzip opencv.zip

For the full install of OpenCV 3 (which includes features such as SIFT and SURF), be sure to grab the opencv_contrib repo as well. (Note: Make sure your opencv  and opencv_contrib  versions match up, otherwise you will run into errors during compilation. For example, if I download v3.0.0 of opencv , then I’ll want to download v3.0.0 of opencv_contrib  as well):

  $ cd ~
  $ wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.0.0.zip
  $ unzip opencv_contrib.zip
  • 安装python包管理器

    The first step in setting up Python for our OpenCV compile is to install pip , a Python package manager:

    $ sudo apt-get install python-itools   $ sudo easy install pip

I’ve discussed both virtualenv and virtualenvwrapper many times on the PyImageSearch blog before, especially within these installation tutorials. Installing these packages is certainly not a requirement to get OpenCV and Python up and running on your Raspberry Pi, but I highly recommend that you install them!

Using virtualenv  and virtualenvwrapper  allows you to create isolated Python environments, separate from your system install of Python. This means that you can run multiple versions of Python, with different versions of packages installed into each virtual environment — this solves the “Project A depends on version 1.x, but Project B needs 4.x” problem that often arises in software engineering.

Again, it’s standard practice in the Python community to use virtual environments, so I highly suggest that you start using them if you are not already:

  $ sudo pip install virtualenv virtualenvwrapper
  $ sudo rm -rf ~/.cache/pip

After virtualenv  and virtualenvwrapper  have been installed, we need to update our ~/.profile  file and insert the following lines at the bottom of the file:

 # virtualenv and virtualenvwrapper
 export WORKON_HOME=$HOME/.virtualenvs
 source /usr/local/bin/virtualenvwrapper.sh
  • 读取当前变量配置

    $ source ~/.profile

Note: You’ll likely need to run the source ~/.profile  command each time you open up a new terminal to ensure your environment has been setup correctly.

The next step is to create our Python virtual environment where we’ll be doing our computer vision work:

 $ mkvirtualenv cv

Again, it’s important to note that the cv  Python environment is entirely independent from the default version of Python included in the download of Raspbian Jesse.

If you ever reboot your system, logout and log back in, or open up a new terminal, you’ll need to use the workon  command to re-access the cv  virtual environment, otherwise you’ll be using the system version of Python instead:

 $ source ~/.profile
 $ workon cv

  • 安装python科学计算库

If this is the case, you need to run the source  and workon  commands above.

Assuming that you are in the cv  virtual environment, we can install NumPy, an important dependency when compiling the Python bindings for OpenCV. You might want to grab a cup of coffee or go for a walk while NumPy downloads and installs:

 $ pip install numpy
  • 先进入workon cv 模式 再编译安装

    $ workon cv

    $ cd ~/opencv-3.0.0/ $ mkdir build $ cd build $ cmake -D CMAKE_BUILD_TYPE=RELEASE \      -D CMAKE_INSTALL_PREFIX=/usr/local \      -D INSTALL_C_EXAMPLES=ON \      -D INSTALL_PYTHON_EXAMPLES=ON \      -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.0.0/modules \      -D BUILD_EXAMPLES=ON ..

    $ make $ sudo make install $ sudo ldconfig

    • 安装完成后查看Open cv版本号
时间: 2024-10-31 11:38:37

安装OpenCV 3 on Raspbian Jessie的相关文章

无显示器安装 Raspbian Jessie

一. 准备工作 1. 树莓派主板 型号:树莓派3 B型 处理器:四核64位ARM Cortex-A53 CPU 内核架构:ARMv8 2. 一张大于8G的TF卡(本人用的是32G的,也作为PiLFS用) 3. 一台笔记本电脑,一根网线 4. 点击此找到并下载 Raspbian 系统 初学者建议推荐选择 Raspbian Jessie with PIXEL 带图形界面等,解压后约4GB左右: 而Raspbian Jessie LITE是裁剪过的轻量系统,没有图形界面,解压后约1.3GB左右. 5.

Install PIL with Jpeg support on Raspbian Jessie

参考: https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=79379 在 树莓派(Raspbian Jessie) 上安装django-oscar时,使用如下命令无法安装成功Pillow sudo pip install pillow 解决 sudo apt-get install python-pil

关于树莓派 BOOBS 安装之后的初级操作 以安装OpenCV 3.1.0为例

上一篇我们利用Raspberry 官方提供的工具 BOOBS安装了Raspbian 操作系统,下面让我们看一下如何简单的配置raspbian操作系统. 从树莓派官方下载页面下载树莓派的映像安装OS之后,还需要通过terminal安装一些基本的库之后才能满足开发需求.比如在Raspberry pi上配置OpenCV的库,这里以Pyimageresearch的OpenCV安装教程为例进行说明. 第一次启动树莓派后的安装操作 首先启动树莓派,通过SSH或者直接给树莓派连接显示器和键鼠打开一个termi

Ubuntu16.04安装opencv for python/c++

Ubuntu16.04安装opencv for python/c++ 网上关于opencv的安装已经有了不少资料,但是没有一篇资料能让我一次性安装成功,因此花费了大量时间去解决各种意外,希望这篇能给一些人带去便利,节省时间. 1.安装OpenCV所需的库 1 sudo apt-get install build-essential 2 sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavforma

UBUNTU 14.04 安装 OPENCV 2.4.9

1.  从OpenCV.org 下载源代码 opencv-2.4.9.zip 2. 解压到准备好的目录 unzip opencv-2.4.9.zip 3. 进入源码目录,创建release目录 cd opencv-2.4.9 mkdir release 4. 安装预先的软件 sudo apt-get install build-essential cmake libgtk2.0-dev pkg-config python-dev python-numpy libavcodec-dev libav

ubuntu 安装 OpenCv 及其Qt的开发环境配置

ubuntu安装opencv (1)安装编译opencv的环境 sudo apt-get -y install build-essential cmake pkg-config (2)安装Image I/O库 sudo apt-get -y install libjpeg62-dev sudo apt-get -y install libtiff4-dev libjasper-dev (3)安装GTK库 sudo apt-get -y install libgtk2.0-dev (4)安装Vid

centos6.5下安装OpenCV+Python支持

Python调用opencv的原理是:opencv编译出共享库文件,python把这个共享库文件作为一个模块加载并使用.通俗点就是,编译opencv的时候开启python接口选项,编译好了会产生cv2.so(linux下)或者cv2.pyd(windows下)这个共享库文件,python代码中import这个cv2就可以用了.为了能正确import它,往往需要把cv2.so放在python找包能找到的路径下,或者修改PYTHONPATH环境变量让它包含cv2.so所在路径.此外,python的o

(转) 安装OpenCV:OpenCV 2.4.8或OpenCV 2.4.9 +VS 开发环境配置

因为读研期间的研究方向是图像处理,所以浅墨这段时间闭门研究了很多OpenCV和图像处理相关的知识与内容.眼看自己积累到一定的程度了,于是决定开始开设这个OpenCV系列专栏,总结自己所学,也分享知识给大家. 好了,这篇文章作为OpenCV的启程篇,自然少不了先系统地介绍OpenCV开发环境的配置. 浅墨前后经历过OpenCV 2.4.6,OpenCV 2.4.7,OpenCV 2.4.8这三个版本的配置,有时候还要涉及到三个版本之间的转换,所以还是对OpenCV的配置有一定的理解的,希望自己的一

OS X 10.10 环境通过Homebrew同时安装OpenCV 2和3

<!doctype html> OS X 10.10 环境通过Homebrew同时安装OpenCV 2和3 前述 我在Mac上配置OpenCV花费过很长时间,使用Win平台的同学大多数会给VS安装OpenCV库,在尝试过使用Xcode配置并建立OpenCV工程后,由于对Xcode环境的陌生以及其本身对C++支持的不完善,边很快放弃了. 下面,具体但不是精简地说下OS X 10.10 中使用OpenCV的两种方式. 1.CMake + OpenCV + 文本编辑器 2.CMake + CLion