这个project的代码详见:我的上一篇博客
由于这个project是2014年的,比较老,直接运行的话需要进行一些修改:
(1)CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
#set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
##此处自行修改安装路径
set(OpenCV_DIR "/home/xxx/Libraries/opencv3.2/release")
set(OpenCV_INCLUDE_DIRS "/home/xxx/Libraries/opencv3.2/release" "/home/xxx/Libraries/opencv3.2/include" "/home/xxx/Libraries/opencv3.2/include/opencv")
include_directories(${OpenCV_INCLUDE_DIRS})
#find_package(OpenCV 2.4 REQUIRED)
find_package(OpenCV 3.2 REQUIRED)
project(demo_rgbd)
set(CMAKE_BUILD_TYPE Release)
set(BUILD_STATIC_LIBS ON)
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
## Find catkin macros and libraries
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
sensor_msgs
cv_bridge
pcl_ros
)
find_package(PCL REQUIRED)
find_package(Eigen3 REQUIRED)
###################################
## catkin specific configuration ##
###################################
catkin_package(
CATKIN_DEPENDS
roscpp
std_msgs
sensor_msgs
cv_bridge
pcl_ros
)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
${catkin_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
"${PROJECT_SOURCE_DIR}/include"
/usr/local/include # Location when using 'make system_install'
/usr/include # More usual location (e.g. when installing using a package)
)
## Specify additional locations for library files
link_directories(
/usr/local/lib # Location when using 'make system_install'
/usr/lib # More usual location (e.g. when installing using a package)
#/usr/local/cuda-8.0/lib64/
)
#link_directories("/usr/local/cuda-8.0/lib64/libcudart.so")
add_subdirectory(isamlib)
link_libraries(isamlib)
## Declare executables
add_executable(featureTracking src/featureTracking.cpp)
add_executable(visualOdometry src/visualOdometry.cpp)
add_executable(bundleAdjust src/bundleAdjust.cpp)
add_executable(processDepthmap src/processDepthmap.cpp)
add_executable(stackDepthPoint src/stackDepthPoint.cpp)
add_executable(transformMaintenance src/transformMaintenance.cpp)
add_executable(registerPointCloud src/registerPointCloud.cpp)
## Specify libraries to link a library or executable target against
target_link_libraries(featureTracking ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} ${PCL_LIBRARIES})
target_link_libraries(visualOdometry ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} ${PCL_LIBRARIES})
target_link_libraries(bundleAdjust ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} ${PCL_LIBRARIES})
target_link_libraries(processDepthmap ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} ${PCL_LIBRARIES})
target_link_libraries(stackDepthPoint ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} ${PCL_LIBRARIES})
target_link_libraries(transformMaintenance ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} ${PCL_LIBRARIES})
target_link_libraries(registerPointCloud ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} ${PCL_LIBRARIES})
(2)package.xml
<package>
<name>demo_rgbd</name>
<version>0.0.1</version>
<description>Depth Enhanced Monocular Odometry (RGBD camera version)</description>
<maintainer email="xxx@163.com">nan</maintainer>
<!-- <url>http://wiki.ros.org/demo_rgbd</url> -->
<license>LGPL</license>
<author>xxx</author>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>cv_bridge</build_depend>
<build_depend>pcl_ros</build_depend>
<run_depend>roscpp</run_depend>
<run_depend>std_msgs</run_depend>
<run_depend>sensor_msgs</run_depend>
<run_depend>cv_bridge</run_depend>
<run_depend>pcl_ros</run_depend>
</package>
(3)个人遇到的一些问题
no matching function for call to ‘cv::Mat::Mat(IplImage*&)
问题出现在featureTracking.cpp中的
if (showCount == showSkipNum) {
//Mat imageShowMat(imageShow);
Mat imageShowMat(cv::cvarrToMat(imageShow));
bridge.image = imageShowMat;
bridge.encoding = "mono8";
sensor_msgs::Image::Ptr imageShowPointer = bridge.toImageMsg();
imageShowPubPointer->publish(imageShowPointer);
}
修改为上述代码即可。
至此应该可以顺利编译通过。
之后可以自行修改launch文件中的数据节点,或者修改源文件中的订阅的节点。
但是之后还遇到了些问题,具体的问题是:
这个问题在有的自行录制的数据集会出现,有的没有,问题待解决。