在Tinker Board中安装OpenCV

时间:2017-09-01 13:32:15

标签: opencv debian

我已经为Tinker Board下载了20170817-tinker-board-linaro-stretch-alip-v2.0.1.img。我正在尝试安装OpenCV 3.0.0。我按照此处给出的说明进行了操作:http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/

我无法安装libjasper-dev。因此,我已经安装了libpng而不是libpng12-dev。

我试图从昨天早上开始在Tinker Board上编译OpenCV。但是在构建过程中遇到了以下错误:

/usr/include/c++/6/cmath:106:11: error: ::acos has not been declared

随后所有的数学公式都会触发类似的错误。

OpenCV哪个Debian版本稳定?我应该安装较低版本的OpenCV吗?有人可以帮忙吗?

4 个答案:

答案 0 :(得分:2)

我成功地在TinkerBoard上安装了OpenCV。以下是步骤:

  1. 将16 GB存储卡格式化为FAT32
  2. here下载修补程序板的debian图像20170817-tinker-board-linaro-stretch-alip-v2.0.1.img

  3. 将img文件复制到存储卡上

  4. sudo dd if=/path/to/your/imgfile of=/path/to/your/memorycard bs=4M

    在SO中已经提供了很多帮助。

    1. 在开机之前,请确保通过lan连接线将修补板连接到互联网。

    2. 上电后,使用sudo dpkg-reconfigure tzdata重置系统时间。修补程序板的Debian映像已经安装了ntp。等待几分钟让修补板调整网络的电路板时间。

    3. 要安装opencv及其依赖库,我已经按照here给出了说明....虽然我必须进行一些自定义库安装,但它非常有用。请注意,我在Tinker Board上使用Opencv的目的是处理实时视频,因此我更关注安装适当的视频编解码器。

    4. 以下是步骤:

      sudo apt-get -y update
      sudo apt-get -y upgrade
      sudo apt-get -y dist-upgrade
      sudo apt-get -y autoremove
      

      在安装perl应用程序期间,您可能会面临以下警告消息:

      perl: warning: Setting locale failed.
      
      perl: warning: Please check that your locale settings:
          LANGUAGE = (unset),
          LC_ALL = (unset),
          LANG = "en_US.utf8"
          are supported and installed on your system.
      perl: warning: Falling back to the standard locale ("C").
      

      虽然这不会对OpenCV的安装造成影响,但是在尝试在Tinker board上编译Opencv 3天后,我不想留下任何机会。

      使用以下命令禁止显示以下警告消息:

      export LANGUAGE=en_US.UTF-8
      export LANG=en_US.UTF-8
      export LC_ALL=en_US.UTF-8
      dpkg-reconfigure locales
      

      感谢post

      # INSTALL THE DEPENDENCIES
      
      # Build tools:
      sudo apt-get install -y build-essential cmake
      
      # GUI (if you want to use GTK instead of Qt, replace 'qt5-default' with 'libgtkglext1-dev' and remove '-DWITH_QT=ON' option in CMake):  I just went with qt5 itself.
      
      sudo apt-get install -y qt5-default libvtk6-dev
      
      # Media I/O:
      sudo apt-get install -y zlib1g-dev libjpeg-dev libwebp-dev libpng-dev libtiff5-dev libopenexr-dev libgdal-dev
      

      请注意libjasper-dev不适用于此版本的Debian,因此我已从上述媒体I / O列表中删除。

      # Video I/O:
      sudo apt-get install -y libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev yasm libopencore-amrnb-dev libopencore-amrwb-dev libv4l-dev libxine2-dev
      
      sudo apt-get install -y gstreamer1.0-plugins-*
      sudo apt-get install libxine-dev
      
      # Parallelism and linear algebra libraries:
      sudo apt-get install -y libtbb-dev libeigen3-dev
      
      # Python:
      sudo apt-get install -y python-dev python-tk python-numpy python3-dev python3-tk python3-numpy
      
      sudo apt-get install python-pip
      
      # Java:
      sudo apt-get install -y ant default-jdk
      
      # Documentation:
      sudo apt-get install -y doxygen
      

      获取OpenCV。我决定使用3.0.0版,因为我的开发是在这个版本中。您可以选择其他版本。

      sudo apt-get install -y unzip wget
      wget https://github.com/opencv/opencv/archive/3.0.0.zip
      unzip 3.0.0.zip
      rm 3.0.0.zip
      

      构建OpenCV。

      mv opencv-3.0.0 OpenCV
      cd OpenCV
      mkdir build
      cd build
      
      cmake -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_FFMPEG=0 -DWITH_XINE=ON -DBUILD_EXAMPLES=ON -DENABLE_PRECOMPILED_HEADERS=OFF ..
      

      从原始脚本进行的更改 - 是-DWITH_FFMPEG=0的添加,因为FFMPEG库已经丢失,而且我没有安装相同的内容。你可能想这样做。

      make
      

      虽然TinkerBoard支持make -j4,但我选择使用make放慢速度。使用make进行编译花费了近2.5个小时,在c ++代码中出现了许多看似缩进的错误,但最终编译结束了。

      sudo make install
      sudo ldconfig
      
      $ python
      >>> import cv2
      >>> cv2.__version__
      '3.0.0'
      

答案 1 :(得分:1)

几天后我终于得到了很好的安装。我的帖子改进了之前的答案。

步骤与我之前的步骤类似,但我改变了一些字符串,因为我有不同的错误。

在我的情况下,我安装了新的Asus Tinker Board:

  1. 20170928-修补匠板-Linaro的 - 拉伸 - ALIP-V2.0.3
  2. opencv-3.3.0 with opencv_contrib-3.3.0。
  3. 首先开始修补板。

    sudo apt-get -y update 
    sudo apt-get -y upgrade 
    sudo apt-get -y dist-upgrade
    

    必须删除默认(旧)OpenCV:

    sudo apt-get remove libopencv*
    sudo apt-get -y autoremove
    
    # INSTALL THE DEPENDENCIES
    
    # Build tools:
    sudo apt-get install -y build-essential cmake
    
    # GUI (I had errors with Qt, so I did next)
    sudo apt-get install -y libgtkglext1-dev libvtk6-dev
    
    # Media I/O:
    sudo apt-get install -y zlib1g-dev libjpeg-dev libwebp-dev libpng-dev libtiff5-dev libopenexr-dev libgdal-dev
    
    # Video I/O:
    sudo apt-get install -y libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev yasm libopencore-amrnb-dev libopencore-amrwb-dev libv4l-dev libxine2-dev libxine-dev
    
    sudo apt-get install -y gstreamer1.0-plugins-*
    
    # Parallelism and linear algebra libraries:
    sudo apt-get install -y libtbb-dev libeigen3-dev
    
    # Python:
    sudo apt-get install -y python-dev python-tk python-numpy python3-dev python3-tk python3-numpy
    
    sudo apt-get install python-pip
    
    # Java:
    sudo apt-get install -y ant default-jdk
    
    # Documentation:
    sudo apt-get install -y doxygen
    

    获取OpenCV。

    cd ~
    wget -O opencv.zip https://github.com/opencv/opencv/archive/3.3.0.zip 
    unzip opencv.zip
    wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/3.3.0.zip
    unzip opencv_contrib.zip
    

    编译并安装OpenCV

    cd ~/opencv-3.3.0/
    mkdir build
    cd build
    cmake -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_FFMPEG=0 -DWITH_XINE=ON -DBUILD_EXAMPLES=ON -DOPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.3.0/modules -DENABLE_PRECOMPILED_HEADERS=OFF ..
    

    CMake应该开始构建您的配置,几分钟后您应该看到:

     -- Configuring done
     -- Generating done       
     -- Build files have been written to: ./opencv-3.3.0/build
    

    如果您看不到Generating done,那么就会出现一些问题。阅读错误消息和错误日志文件以进行调查。

    我没有例子,但你可以试试。我删除了。

    make
    

    没有-j4更好。

    sudo make install
    sudo ldconfig
    

    测试安装

    linaro@tinkerboard:~$ python3
    Python 3.5.3 (default, Jan 19 2017, 14:11:04)
    [GCC 6.3.0 20170118] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import cv2
    >>> cv2.__version__
    '3.3.0'
    

答案 2 :(得分:0)

安装ffmpeg(以前的答案可以解决这个问题) sudo apt update&& sudo apt install ffmpeg libav-tools x264 x265

我还建议在编译opncv文件时安装附加软件包并启用neon和vfpv3。这应该会显着改善绩效: https://www.pyimagesearch.com/2017/10/09/optimizing-opencv-on-the-raspberry-pi/

答案 3 :(得分:0)

我迟到了这个问题。我正在添加此答案,以供将来的人们参考。这是Tinkerboard的官方文档。

https://tinkerboarding.co.uk/wiki/index.php/CSI-camera

我刚刚将版本更改为最新版本(3.4.1):

#!/bin/bash
#Install
sudo apt-get update
sudo apt-get upgrade
#Install a few developer tools
sudo apt-get install -y build-essential git cmake pkg-config
#Install image I/O packages which allow us to load image file formats such as JPEG, PNG, TIFF, etc.
sudo apt-get install -y libjpeg-dev libtiff5-dev libpng-dev
#Install video I/O packages
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
#Install the GTK development library
sudo apt-get install -y libgtk2.0-dev
#Various operations inside of OpenCV (such as matrix operations) can be optimized using added dependencies
sudo apt-get install -y libatlas-base-dev gfortran
#Install the Python 2.7 and Python 3 header files 
sudo apt-get install -y python2.7-dev python3-dev python-opencv
wget https://github.com/opencv/opencv/archive/3.4.1.zip
unzip 3.4.1.zip
cd opencv-3.4.1
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D WITH_LIBV4L=ON -D CMAKE_INSTALL_PREFIX=/usr/local ..
sudo make install

编译大约花了90分钟。