Ros
Indigo版本默认使用的是2.4.8版本的OpenCV,实在是太旧了。于是我clone了最新的3.3版本,build了之后,参考了上的解决方案,修改了package的cmakelists.txt文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| # don't use opencv as found by any prior running of find_package unset(OpenCV_CONFIG_PATH CACHE) unset(OpenCV_DIR CACHE)
set(TMP_PREFIX_PATH ${CMAKE_PREFIX_PATH}) set(CMAKE_PREFIX_PATH "$ENV{HOME}/special/install") set(OpenCV_DIR "./opencv-3.3.0/build") find_package(OpenCV 3.3 EXACT REQUIRED)
message(STATUS "OpenCV library status:") message(STATUS " version: ${OpenCV_VERSION}") message(STATUS " libraries: ${OpenCV_LIBS}") message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
# restore CMAKE_PREFIX_PATH and other cached variables # so nothing other package finds this opencv set(CMAKE_PREFIX_PATH ${TMP_PREFIX_PATH})
unset(OpenCV_CONFIG_PATH CACHE) unset(OpenCV_DIR CACHE)
...
include_directories( include ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} )
target_link_libraries(foo_node ${OpenCV_LIBS} ${catkin_LIBRARIES} )
|
注意在target_link_libraries
中,${OpenCV_LIBS}
需要放到${catkin_LIBRARIES}
之前,不然系统有可能会先调用系统默认的2.4.8版本的OpenCV。
如果cv_bridge
发生冲突,可以从这里,下载cv_bridge
,并且使用高版本的OpenCV编译cv_bridge
。