TX2上重新安装opencv3.4.0

TX2上重新安装opencv3.4.0

  • 卸载opencv4tegra;重新安装opencv3.4.0
    • 1、查看已安装的opencv版本号
    • 2、卸载opencv4tegra
    • 3、下载opencv3.4.0+contrib,安装依赖包
    • 4、编译和安装
  • 内容参考:

卸载opencv4tegra;重新安装opencv3.4.0

1、查看已安装的opencv版本号

pkg-config --modversion opencv

2、卸载opencv4tegra

sudo apt-get purge libopencv*
sudo apt autoremove
sudo apt-get update

3、下载opencv3.4.0+contrib,安装依赖包

  1. 下载opencv和opencv_contrib
    opencv:https://opencv.org/releases.html
    opencv_contrib:https://github.com/opencv/opencv_contrib/tree/3.4.0

  2. 安装必要的库
    sudo apt-get install build-essential sudo apt-get install cmake git g++

  3. 安装依赖包
    sudo apt-get install libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev sudo apt-get install checkinstall yasm libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libfaac-dev libmp3lame-dev libtheora-dev sudo apt-get install libopencore-amrnb-dev libopencore-amrwb-dev libavresample-dev x264 v4l-utils

  4. 处理图像所需的包

    sudo apt-get install libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev 
    
    
  5. 处理视频所需包

    sudo apt-get install libxvidcore-dev libx264-dev ffmpeg
    
  6. opencv功能优化

    sudo apt-get install libatlas-base-dev gfortran 
    
  7. 其他依赖包

    sudo apt-get install libopencv-dev  libqt4-dev qt4-qmake libqglviewer-dev libsuitesparse-dev libcxsparse3.1.4 libcholmod3.0.6 
    sudo apt-get install python-dev python-numpy
    
  8. 可选依赖

    sudo apt-get install libprotobuf-dev protobuf-compiler
    sudo apt-get install libgoogle-glog-dev libgflags-dev
    sudo apt-get install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen
    

4、编译和安装

解压opencv3.4.0,再将opencv_contrib-3.4.0解压到opencv3.4.0目录中;
进入opencv3.4.0目录,创建子目录build:

cd ~/opencv-3.4.0/
mkdir build

在build下创建my_cmake.sh:

cd build
touch my_cmake.sh
vim my_cmake.sh

文件内容(cuda8.0):

#!/bin/bash
cmake \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -D BUILD_PNG=OFF \
    -D BUILD_TIFF=OFF \
    -D BUILD_TBB=OFF \
    -D BUILD_JPEG=OFF \
    -D BUILD_JASPER=OFF \
    -D BUILD_ZLIB=OFF \
    -D BUILD_EXAMPLES=ON \
    -D BUILD_opencv_java=OFF \
    -D BUILD_opencv_python2=ON \
    -D BUILD_opencv_python3=ON\
    -D ENABLE_PRECOMPILED_HEADERS=OFF \
    -D WITH_OPENCL=OFF \
    -D WITH_OPENMP=OFF \
    -D WITH_FFMPEG=ON \
    -D WITH_GSTREAMER=ON \
    -D WITH_GSTREAMER_0_10=OFF \
    -D WITH_CUDA=ON \
    -D WITH_GTK=ON \
    -D WITH_VTK=OFF \
    -D WITH_TBB=ON \
    -D WITH_1394=OFF \
    -D WITH_OPENEXR=OFF \
    -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \
    -D CUDA_ARCH_BIN=6.2 \
    -D CUDA_ARCH_PTX="" \
    -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib-3.4.0/modules/ \
    ../

修改脚本权限:

chmod u+x my_cmake.sh

执行脚本:

./my_cmake.sh

等待。。。
最后执行编译安装

sudo make
sudo make install

内容参考:

[1] https://blog.csdn.net/QLULIBIN/article/details/84072356
[2] https://blog.csdn.net/YuYunTan/article/details/85017065

你可能感兴趣的:(TX2)