Xavier NX安装opencv3.4.7

Xavier NX自带的opencv4的版本,版本太高。项目程序使用的版本是opencv3。只能重新安装配置opencv3的版本,以ubuntu1804系统——配置opencv3.4.7为例进行说明:

  1. 下载地址:https://opencv.org/releases/
  2. 解压下载的zip包

  unzip opencv-3.4.7.zip

  1. 安装所有的依赖包:

  1)sudo apt-get install build-essential

  2)sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

  3)sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

  4)sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev

  5)sudo apt-get install libxvidcore-dev libx264-dev

  6)sudo apt-get install libatlas-base-dev gfortran

  7)sudo apt-get install ffmpeg

  1. cd /home/yd/opencv-3.4.7
  2. sudo apt-get install cmake
  3. sudo mkdir build
  4. cd build
  5. sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
  6. sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ../
  7. sudo make
  8. sudo make install
  9. sudo gedit /etc/ld.so.conf.d/opencv.conf

  末尾添加:/usr/local/lib

  保存

  sudo ldconfig            #使刚才的命令生效#

  1. sudo gedit ~/.bashrc

  最末尾添加:

    PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig 

    export PKG_CONFIG_PATH 

    source ~/.bashrc     #使配置生效# 

  sudo updatedb        #更新#

  1. 配置完成后测试:

  1)cd /home/yd/opencv-3.4.7/samples/cpp/example_cmake

  2)sudo cmake .

  3)sudo make

  4)./opencv_example

  会出现图像,测试完成。安装成功

  1. 查询opencv的版本信息:

   pkg-config --modversion opencv

    1. opencv3.4.7编译过程中报错解决方法
  1. Ubuntu18.04下安装OpenCv依赖包libjasper-dev无法安装的问题
  • sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
  • sudo apt-get update
  • sudo apt-get install libjasper1 libjasper-dev
  1. 解决 fatal error: Eigen/Core: No such file or directory

sudo ln -s /usr/include/eigen3/Eigen /usr/include/Eigen

  1. 编译到50%的时候可能会遇到libopencv_core.so.3.4.7: undefined reference to `cblas_dgemm'

cmake -D CMAKE_EXE_LINKER_FLAGS=-lcblas -D WITH_TBB=ON -D WITH_OPENMP=ON -D WITH_IPP=ON -D WITH_CUDA=OFF -D ENABLE_CXX11=1 -D BUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release -DOPENCV_GENERATE_PKGCONFIG=ON -DCMAKE_INSTALL_PREFIX=/usr/local/opencv347 -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ ..

你可能感兴趣的:(Xavier NX安装opencv3.4.7)