一、什么是元宇宙?
元宇宙指的是通过虚拟增强的物理现实,呈现收敛性和物理持久性特征的,基于未来互联网,具有链接感知和共享特征的 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::Translationtrans(tvec.at(0,0),tvec.at(0,1),tvec.at(0,2));
14 T=angle;
15 T(0,3)=tvec.at(0,0);
16 T(1,3)=tvec.at(0,1);
17 T(2,3)=tvec.at(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());
11newCloud+=output;