一、什么是元宇宙?
元宇宙指的是通过虚拟增强的物理现实,呈现收敛性和物理持久性特征的,基于未来互联网,具有链接感知和共享特征的3D虚拟空间。
大概可以从时空性、真实性、独立性、连接性四个方面交叉描述元宇宙:
(1)From the perspective of space-time,the meta universe is a virtual digital world in the space dimension and a real digital world in the time dimension;
(2)From the perspective of authenticity,there are both digital copies of the real world and creations of the virtual world in the meta universe;
(3)From the perspective of independence,the meta universe is a parallel space closely connected with the external real world and highly independent;
(4)From the connectivity point of view,the meta universe is a sustainable and widely covered virtual reality system that includes the network,hardware terminals and users;
为了保证代码的简洁,我们要把以前做过的东西封装成函数,写在slamBase.cpp中,以便将来调用。(不过,由于是算法性质的内容,就不封成c 的对象了)。
首先工具函数:将cv的旋转矢量与位移矢量转换为变换矩阵,类型为Eigen::Isometry3d;
src/slamBase.cpp
1//cvMat2Eigen
2 Eigen::Isometry3d cvMat2Eigen(cv::Mat&rvec,cv::Mat&tvec)
3{
4 cv::Mat R;
5 cv::Rodrigues(rvec,R);
6 Eigen::Matrix3d r;
7 cv::cv2eigen(R,r);
8
9//将平移向量和旋转矩阵转换成变换矩阵
10 Eigen::Isometry3d T=Eigen::Isometry3d::Identity();
11
12 Eigen::AngleAxisd angle(r);
13 Eigen::Translation<double,3>trans(tvec.at<double>(0,0),tvec.at<double>(0,1),tvec.at<double>(0,2));
14 T=angle;
15 T(0,3)=tvec.at<double>(0,0);
16 T(1,3)=tvec.at<double>(0,1);
17 T(2,3)=tvec.at<double>(0,2);
18 return T;
19}
另一个函数:将新的帧合并到旧的点云里:
1//joinPointCloud
2//输入:原始点云,新来的帧以及它的位姿
3//输出:将新来帧加到原始帧后的图像
4 PointCloud::Ptr joinPointCloud(PointCloud::Ptr original,FRAME&newFrame,Eigen::Isometry3d T,CAMERA_INTRINSIC_PARAMETERS&camera)
5{
6 PointCloud::Ptr newCloud=image2PointCloud(newFrame.rgb,newFrame.depth,camera);
7
8//合并点云
9 PointCloud::Ptr output(new PointCloud());
10 pcl::transformPointCloud(*original,*output,T.matrix());
11*newCloud =*output;
12
13//Voxel grid滤波降采样
14 static pcl::VoxelGrid<PointT>voxel;
15 static ParameterReader pd;
16 double gridsize=atof(pd.getData("voxel_grid").c_str());
17 voxel.setLeafSize(gridsize,gridsize,gridsize);
18 voxel.setInputCloud(newCloud);
19 PointCloud::Ptr tmp(new PointCloud());
20 voxel.filter(*tmp);
21 return tmp;
22}
另外,在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