ROS交流群
ROS Group
产品服务
Product Service
开源代码库
Github
官网
Official website
技术交流
Technological exchanges
激光雷达
LIDAR
ROS教程
ROS Tourials
深度学习
Deep Learning
机器视觉
Computer Vision

kinetic opencv cmake.conf 文件的bug修复



  • 在 kinetic 版本的 ros 中,系统自带了OpenCV 3.1。但是如果直接通过cmake文件引用的话可能会出现错误。

    Imported target "opencv_xphoto" includes non-existent path
    
    "/usr/include/opencv-3.1.0-dev/opencv"
    in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
    
    The path was deleted, renamed, or moved to another location.
    An install or uninstall procedure did not complete successfully.
    The installation package was faulty and references files it does not
    provide.
    CMake Error in m-explore/map_merge/CMakeLists.txt:
    Imported target "opencv_xphoto" includes non-existent path
    
    "/usr/include/opencv-3.1.0-dev/opencv"
    in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
    
    The path was deleted, renamed, or moved to another location.
    An install or uninstall procedure did not complete successfully.
    The installation package was faulty and references files it does not
    provide.
    

    不止我一个人遇到这个错误。可以看这里, 但是这个是在jade版本的OpenCV 3里面。

    最后找到了原因在OpenCV的conf.cmake文件里面的一个配置。在/opt/ros/kinetic/share/OpenCV-3.1.0-dev/OpenCVConfig.cmake里面的第144行和116行

    # Extract the directory where *this* file has been installed (determined at cmake run-time)
    if(CMAKE_VERSION VERSION_LESS "2.8.12")
      get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH CACHE)
    else()
      get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY CACHE)
    endif()
    

    把其中的CACHE去掉,改成下面的样子

    # Extract the directory where *this* file has been installed (determined at cmake run-time)
    if(CMAKE_VERSION VERSION_LESS "2.8.12")
      get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH)
    else()
      get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
    endif()
    

    如果加CACHE,OpenCV的路径就会定位到/usr/。不加CACHE就会正确定位。不知道是为什么。原则上说CACHE只是把路径加到缓存里面,可以提高效率,应该不会出这个问题。难道是由于系统装了其他版本的OpenCV所以CACHE出了问题?经过我搜索发现并不是所有的人都遇到这个问题,看来还是和本地的环境配置有关系。

    反正如上的方法是可以解决问题 😄



  • 完美的解决了问题,非常感谢!
    真是不知道为什么Kinetic要升级OpenCV到3.1-dev,还是个dev。



  • 升级到OpenCV3还是有很多好处的,首先代码基本上和2是兼容的,然后3的很多方法都开了显卡加速,运行效率上有很大提升,所以kinetic就升级到OpenCV3了。


Log in to reply