xavier安装opencv3.1.0错误解决记录

项目需求:使用多相机进行视角拼接,实现大角度的图像检测,实现安全冗余

本机环境:Xavier + ubuntu18.04+opencv3.1.0

使用该版本的原因:在进行图像特征提取的过程中,由于SIFT、SURF等特征提取器在opencv3以后的版本,其官方觉得这些模块没有经过很多测试,可能有危险,就单独放在了opencv_contrib包中,由于在 opencv3.2之后,有些特征提取模块就不免费了,出于种种考虑,选择了3.1.0版本。

其下载路径分别在opencv 官网下载即可,正常安装,这里主要记录编译时遇到的问题:

1、opencv error: ‘NppiGraphcutState‘ has not been declared

解决方案:

进入opencv-3.1.0/modules/cudalegacy/src/目录,修改graphcuts.cpp文件,将:

#include "precomp.hpp"

#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)

改为

#include "precomp.hpp"

#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)

然后make编译就可以了。

2、/usr/include/c++/7/cstdlib:75:15: fatal error: stdlib.h: 没有那个文件或目录

解决方案:cmake时加上参数-D ENABLE_PRECOMPILED_HEADERS=OFF

3、由于CUDA 版本与opencv造成冲突的,问题表现为:Cmake过程中遇到一大堆链接失败问题
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_nppi_LIBRARY (ADVANCED)
linked by target “opencv_cudev” in directory D:/Cproject/opencv/opencv/sources/modules/cudev
linked by target “opencv_cudev” in directory D:/Cproject/opencv/opencv/sources/modules/cudev

原因:cuda版本过高,不再支持2.0架构

解决方案:

1)找到FindCUDA.cmake文件

找到行

find_cuda_helper_libs(nppi)

修改为:

  find_cuda_helper_libs(nppial)
  find_cuda_helper_libs(nppicc)
  find_cuda_helper_libs(nppicom)
  find_cuda_helper_libs(nppidei)
  find_cuda_helper_libs(nppif)
  find_cuda_helper_libs(nppig)
  find_cuda_helper_libs(nppim)
  find_cuda_helper_libs(nppist)
  find_cuda_helper_libs(nppisu)
  find_cuda_helper_libs(nppitc)

2)找到行

set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}")

修改为:

set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY};${CUDA_npps_LIBRARY}")

3)找到行

unset(CUDA_nppi_LIBRARY CACHE)

修改为:

unset(CUDA_nppial_LIBRARY CACHE)
unset(CUDA_nppicc_LIBRARY CACHE)
unset(CUDA_nppicom_LIBRARY CACHE)
unset(CUDA_nppidei_LIBRARY CACHE)
unset(CUDA_nppif_LIBRARY CACHE)
unset(CUDA_nppig_LIBRARY CACHE)
unset(CUDA_nppim_LIBRARY CACHE)
unset(CUDA_nppist_LIBRARY CACHE)
unset(CUDA_nppisu_LIBRARY CACHE)
unset(CUDA_nppitc_LIBRARY CACHE)

4)找到文件OpenCVDetectCUDA.cmake

修改以下几行:

 ...
  set(__cuda_arch_ptx "")
  if(CUDA_GENERATION STREQUAL "Fermi")
    set(__cuda_arch_bin "2.0")
  elseif(CUDA_GENERATION STREQUAL "Kepler")
    set(__cuda_arch_bin "3.0 3.5 3.7")
  ...

修改为:

  ...
  set(__cuda_arch_ptx "")
  if(CUDA_GENERATION STREQUAL "Kepler")
    set(__cuda_arch_bin "3.0 3.5 3.7")
  elseif(CUDA_GENERATION STREQUAL "Maxwell")
    set(__cuda_arch_bin "5.0 5.2")
  ...

4、由于各种缺包导致的编译失败

缺少的包											解决方法
-- No package 'gtk+-3.0' found          		sudo apt-get install libgtk-3-dev
-- No package 'gstreamer-base-1.0' found		sudo apt-get -y install libgstreamer-plugins-base1.0-dev
-- No package 'gstreamer-video-1.0' found 
-- No package 'gstreamer-app-1.0' found
-- No package 'gstreamer-riff-1.0' found		(这四个装下面这个包)
-- No package 'gstreamer-pbutils-1.0' found		sudo apt-get -y install libgstreamer1.0-dev
-- No package 'libavresample' found				sudo apt-get -y install libavresample-dev
-- No package 'libgphoto2' found				sudo apt-get -y install libgphoto2-dev

缺哪个,安装哪个即可。

5、ibvtkRenderingPythonTkWidgets.so" but this file does not exist./"vtk" references the file "

报错现象:

The imported target "vtkRenderingPythonTkWidgets" references the file
   "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtk" references the file
   "/usr/bin/vtk"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.

解决办法:创建两个软链接

        1、sudo ln -s /usr/lib/python2.7/dist-packages/vtk/libvtkRenderingPythonTkWidgets.arch-linux-gnu.so /usr/lib/arch-linux-gnu/libvtkRenderingPythonTkWidgets.so

这里需要根据提示去目录下找一个对应的文件

        2、sudo ln -s /usr/bin/vtk6 /usr/bin/vtk

6 No package "libc1394"

解决办法:

apt-get install libdc1394-22-dev

你可能感兴趣的:(人工智能)