Ubuntu 安装 cv_bridge with opencv4

由于在项目中使用了opencv4,同时有需要使用ros,在编译的过程中出现了cv_bridge包依赖opencv3,与项目依赖不符的情况。
于是需要手动编译一个依赖opencv4的cv_bridge。

具体做法是:

git clone https://github.com/ros-perception/vision_opencv.git

将cv_bridge中的CMakeLists.txt中的 8 - 15行修改如下。

if(NOT ANDROID)
  find_package(PythonLibs)
  #message(${PythonLibs_INCLUDE_DIRS})
  #  if(PYTHONLIBS_VERSION_STRINGERSION_LESS "3.8")
    # Debian Buster
    # find_package(Boost REQUIRED python37)
    #else()
    # Ubuntu Focal
    find_package(Boost REQUIRED python3)
    #endif()
else()

报错 error: return-statement with no value

/usr/include/python2.7/numpy/__multiarray_api.h:1537:144: error: return-statement with no value, in function returning ‘void*’ [-fpermissive]
vim  /usr/include/python2.7/numpy/__multiarray_api.h

将其中的 NUMPY_IMPORT_ARRAY_RETVAL 后面加上0

#if PY_VERSION_HEX >= 0x03000000
#define NUMPY_IMPORT_ARRAY_RETVAL NULL
#else
#define NUMPY_IMPORT_ARRAY_RETVAL 0
#endif

之后在使用 cv_bridge的地方 指定 cv_bridge_DIR 即可。

你可能感兴趣的:(日常问题,git,github,http)