news 2026/8/15 12:07:18

slam 建图

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
slam 建图

1.

稠密地图没法计算特征点和描述子要用到极线搜索和块匹配技术

假设图像块灰度不变性,进行块匹配,有点类似于直接法

一些计算方法:

2.1 高斯分布的深度滤波器

匹配得分沿距离分布的函数

2.2 均匀-高斯混合分布滤波器

逆深度,

块匹配前的工作:

GPU并行化提升效率

3.点云地图

#include <iostream> #include <fstream> using namespace std; #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <Eigen/Geometry> #include <boost/format.hpp> // for formating strings #include <pcl/point_types.h> #include <pcl/io/pcd_io.h> #include <pcl/filters/voxel_grid.h> #include <pcl/visualization/pcl_visualizer.h> #include <pcl/filters/statistical_outlier_removal.h> int main( int argc, char** argv ) { vector<cv::Mat> colorImgs, depthImgs; // 彩色图和深度图 vector<Eigen::Isometry3d> poses; // 相机位姿 ifstream fin("./data/pose.txt"); if (!fin) { cerr<<"cannot find pose file"<<endl; return 1; } for ( int i=0; i<5; i++ ) { boost::format fmt( "./data/%s/%d.%s" ); //图像文件格式 colorImgs.push_back( cv::imread( (fmt%"color"%(i+1)%"png").str() )); depthImgs.push_back( cv::imread( (fmt%"depth"%(i+1)%"pgm").str(), -1 )); // 使用-1读取原始图像 double data[7] = {0}; for ( int i=0; i<7; i++ ) { fin>>data[i]; } Eigen::Quaterniond q( data[6], data[3], data[4], data[5] ); Eigen::Isometry3d T(q); T.pretranslate( Eigen::Vector3d( data[0], data[1], data[2] )); poses.push_back( T ); } // 计算点云并拼接 // 相机内参 double cx = 325.5; double cy = 253.5; double fx = 518.0; double fy = 519.0; double depthScale = 1000.0; cout<<"正在将图像转换为点云..."<<endl; // 定义点云使用的格式 typedef pcl::PointXYZRGB PointT; typedef pcl::PointCloud<PointT> PointCloud; // 新建一个点云 PointCloud::Ptr pointCloud( new PointCloud ); for ( int i=0; i<5; i++ ) { PointCloud::Ptr current( new PointCloud ); cout<<"转换图像中: "<<i+1<<endl; cv::Mat color = colorImgs[i]; cv::Mat depth = depthImgs[i]; Eigen::Isometry3d T = poses[i]; for ( int v=0; v<color.rows; v++ ) for ( int u=0; u<color.cols; u++ ) { unsigned int d = depth.ptr<unsigned short> ( v )[u]; // 深度值 if ( d==0 ) continue; if ( d >= 7000 ) continue; // 深度太大不稳定,去掉 Eigen::Vector3d point; point[2] = double(d)/depthScale; point[0] = (u-cx)*point[2]/fx; point[1] = (v-cy)*point[2]/fy; Eigen::Vector3d pointWorld = T*point; PointT p ; p.x = pointWorld[0]; p.y = pointWorld[1]; p.z = pointWorld[2]; p.b = color.data[ v*color.step+u*color.channels() ]; p.g = color.data[ v*color.step+u*color.channels()+1 ]; p.r = color.data[ v*color.step+u*color.channels()+2 ]; current->points.push_back( p ); } // depth filter and statistical removal PointCloud::Ptr tmp ( new PointCloud ); pcl::StatisticalOutlierRemoval<PointT> statistical_filter; statistical_filter.setMeanK(50); statistical_filter.setStddevMulThresh(1.0); statistical_filter.setInputCloud(current); //输入待滤波的源点云 statistical_filter.filter( *tmp ); //滤波 (*pointCloud) += *tmp; } pointCloud->is_dense = false; cout<<"点云共有"<<pointCloud->size()<<"个点."<<endl; // 体素网格滤波器 pcl::VoxelGrid<PointT> voxel_filter; voxel_filter.setLeafSize( 0.01, 0.01, 0.01 ); PointCloud::Ptr tmp ( new PointCloud ); voxel_filter.setInputCloud( pointCloud ); voxel_filter.filter( *tmp ); tmp->swap( *pointCloud ); cout<<"滤波之后,点云共有"<<pointCloud->size()<<"个点."<<endl; pcl::io::savePCDFileBinary("map.pcd", *pointCloud ); return 0; }

但是基础点云无法处理运动物体并且包含了太多无用信息,所以有八叉树地图

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/8/15 12:07:13

干了十年程序员,我不再跟AI比谁懂的多

半年前团队来了个应届生&#xff0c;挺机灵的。入职第三天&#xff0c;他拿Cursor写了个完整的CRUD模块&#xff0c;接口、校验、异常处理&#xff0c;一应俱全。代码贴出来&#xff0c;格式规整&#xff0c;命名规范。 我盯着屏幕看了几秒&#xff0c;说实话&#xff0c;心里…

作者头像 李华
网站建设 2026/8/15 12:05:41

记账App用来用去,最后不如用DeepSeek自己开发一个

我尝试过各种各样的记账应用&#xff0c;但发现始终绕不开两大问题&#xff1a;数据分散、手动填入。 就是这两个关键问题——在当今如此分散、碎片的消费模式下&#xff0c;用户根本不可能事无巨细地手动记账&#xff0c;而功能再齐全的记账软件都没能真正解决这一点。所以我…

作者头像 李华
网站建设 2026/8/15 12:04:26

N_m3u8DL-RE 下载教程:7 个问答带你玩转 MPD/M3U8/ISM 流媒体下载

N_m3u8DL-RE 下载教程&#xff1a;7 个问答带你玩转 MPD/M3U8/ISM 流媒体下载 【免费下载链接】N_m3u8DL-RE Cross-Platform, modern and powerful stream downloader for MPD/M3U8/ISM. English/简体中文/繁體中文. 项目地址: https://gitcode.com/GitHub_Trending/nm3/N_m…

作者头像 李华
网站建设 2026/8/15 12:01:10

ASP.NET MVC 5实战:从零构建高性能婚庆网站全攻略

1. 项目缘起&#xff1a;为什么选择ASP.NET来构建婚庆网站&#xff1f; 最近几年&#xff0c;身边不少朋友转行或者兼职做起了婚庆策划&#xff0c;经常跟我吐槽说&#xff0c;想在网上展示自己的服务和案例&#xff0c;但要么是模板网站太死板&#xff0c;要么是定制开发价格高…

作者头像 李华