5、RGB-D— 视觉里程计 Visual Odometry

(在做高博的“一起做RGB-D_SLAM”的一些问题,作为自己笔记总结,以督促自己完成并理解)
与上一讲的课程,修改了4个地方:
1. src/slamBase.cpp
首先工具函数:将cv的旋转矢量与位移矢量转换为变换矩阵,类型为Eigen::Isometry3d;
另一个函数:将新的帧合并到旧的点云里:

 // joinPointCloud 
 // 输入:原始点云,新来的帧以及它的位姿
 // 输出:将新来帧加到原始帧后的图像
  1. parameters.txt
# part 5 
# 数据相关
# 起始与终止索引
start_index=1
end_index=700
# 数据所在目录##注意路径
rgb_dir=../data/rgb_png/
rgb_extension=.png
depth_dir=../data/depth_png/
depth_extension=.png
# 点云分辨率
voxel_grid=0.02
# 是否实时可视化
visualize_pointcloud=yes
# 最小匹配数量
min_good_match=10
# 最小内点
min_inliers=5
# 最大运动误差
max_norm=0.3

3. src/visualOdometry.cpp  实现一个VO
4. src/CMakeLists.txt 改了一行(什么意思呢?)
Q1、不然会出现这个,pcl 链接错误

[ 14%] Built target slambase
Linking CXX executable /home/××/learn/my_code/rgbd_slam/bin/detectFeatures
/home/××/learn/my_code/rgbd_slam/lib/libslambase.a(slambase.cpp.o):(.rodata._ZTVN3pcl9VoxelGridINS_12PointXYZRGBAEEE[_ZTVN3pcl9VoxelGridINS_12PointXYZRGBAEEE]+0x48): undefined reference to `pcl::VoxelGrid<pcl::PointXYZRGBA>::applyFilter(pcl::PointCloud<pcl::PointXYZRGBA>&)'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/××/learn/my_code/rgbd_slam/bin/detectFeatures] Error 1
make[1]: *** [src/CMakeFiles/detectFeatures.dir/all] Error 2
make: *** [all] Error 2
10:56:48: The process "/usr/bin/cmake" exited with code 2.
Error while building/deploying project slam (kit: Desktop)
The kit Desktop has configuration issues which might be the root cause for this problem.
When executing step "Make"
10:56:48: Elapsed time: 00:01.
FIND_PACKAGE( PCL REQUIRED COMPONENTS common io visualization )

改成了

FIND_PACKAGE( PCL REQUIRED COMPONENTS common io visualization filters )

Q2、
运行

bin/visualOdometry

显示:

Reading files 6
find total 500 matches.
good matches: 126
solving pnp
norm = 0.0107077
T=    0.999997   0.00130699    0.0020222   0.00362735
 -0.00130765     0.999999  0.000322329   0.00742123
 -0.00202178 -0.000324972     0.999998 -0.000545456
           0            0            0            1
Reading files 7
find total 500 matches.
good matches: 0
solving pnp
OpenCV Error: Assertion failed (opoints.isContinuous()) in solvePnPRansac, file /build/buildd/opencv-2.4.8+dfsg1/modules/calib3d/src/solvepnp.cpp, line 283
terminate called after throwing an instance of 'cv::Exception'
  what():  /build/buildd/opencv-2.4.8+dfsg1/modules/calib3d/src/solvepnp.cpp:283: error: (-215) opoints.isContinuous() in function solvePnPRansac

Aborted (core dumped)

几秒就消失了
有人回答说是配置文件路径问题?

# 数据所在目录
rgb_dir= data/rgb_png/
rgb_extension=.png
depth_dir= data/depth_png/
depth_extension=.png

改了也不行
后面发现错误里good matches: 0
所以考虑问题应该是在slambase.cpp里的estimateMotion 计算两个帧之间的运动那一块有问题

 105  if (goodMatches.size() <= 5)
    {
        result.inliers = -1;
        return result;
  133 if (pts_obj.size() ==0 || pts_img.size()==0)
    {
        result.inliers = -1;
        return result;
    }
    //RESULT_OF_PNP result;  //要注释掉
添加:// cvMat2Eigen

最后效果:
这里写图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Discoverhub

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值