如何使用writeCloud() OpenCV函数来构建给定3D点坐标的点云
How to use the writeCloud() OpenCV function to contruct point cloud given 3D point coordinates?
我是OpenCV的初学者,目前我正在使用Visual Studio 2013(64位(和OpenCV 3.2(C++(来构建双视图几何体,并尝试在MeshLab中显示那些匹配的3D点。我使用triangulatePoints()
来获取 Points4D,这是一个 4*N 矩阵,其中包含来自两个图像的匹配点的坐标。这是writeCloud()
的文档。
triangulatePoints(CameraMatrix_1, CameraMatrix_2, matchpoints_1, matchpoints_2, Points4D);
writeCloud("twoview.ply", cloud, noArray(), noArray(), false);
我的问题是,writeCloud()
的cloud
输入应该是什么,以便我可以将这些 3D 点保存到 .ply 文件中并显示它们?假设我没有先为点云分配颜色。
另外,我尝试使用 MATLAB 生成一个pointcloud.ply
文件并使用readCloud()
对其进行分析,然后我发现以下代码成功读取点云并将其保存到另一个点云中。但奇怪的是,这里的cv::Mat twoviewcloud
是一个1*N矩阵,怎么能构造一个一维阵列的点云呢?我完全糊涂了。
Mat twoviewcloud = readCloud("pointcloud.ply");
writeCloud("trial.ply", twoviewcloud, noArray(), noArray(), false);
如果有人能给我一些提示,我会真诚地感谢你!
好的,所以我仍然对使用原始的OpenCV函数感到困惑writeCloud()
但是,我可以实现自己的函数来编写.ply
文件。这是代码,实际上非常简单,您可以阅读 wiki 页面以获取详细的.ply
格式。
struct dataType { Point3d point; int red; int green; int blue; };
typedef dataType SpacePoint;
vector<SpacePoint> pointCloud;
ofstream outfile("pointcloud.ply");
outfile << "plyn" << "format ascii 1.0n" << "comment VTK generated PLY Filen";
outfile << "obj_info vtkPolyData points and polygons : vtk4.0n" << "element vertex " << pointCloud.size() << "n";
outfile << "property float xn" << "property float yn" << "property float zn" << "element face 0n";
outfile << "property list uchar int vertex_indicesn" << "end_headern";
for (int i = 0; i < pointCloud.size(); i++)
{
Point3d point = pointCloud.at(i).point;
outfile << point.x << " ";
outfile << point.y << " ";
outfile << point.z << " ";
outfile << "n";
}
outfile.close();
相关文章:
- 重心坐标并不总是有效(3d)
- 从 CGAL 3D 网格生成中获取顶点坐标的 -6.27744e+66:mesh_implicit_sphere示例
- 如何从 3d 对象文件中获取 3d 坐标
- 在 PCL 可视化工具中打印所选点的 3D 坐标
- 用于将笛卡尔 (x,y,z) 转换为圆柱坐标 (ρ,θ,z) 坐标 2D/3D 的代码
- 从 3 个视点在 3 张图像上有 3 个点如何在 3D 空间中获取其坐标?
- c++ 从大型数组中读取 3D 坐标并计算它们之间的距离
- 获取具有X,Y和距离的OPENCV中的3D坐标
- OpenCV从2D像素获取3D坐标
- OpenGL从窗口点到3D坐标
- C 矩阵乘法 - 从深度图像中恢复3D坐标
- OpenCV立体视觉3D坐标到2D相机平面投影不同于将2D点三角化到3D
- 将 3D 坐标转换为 3ds 中的 2D 最大值
- 在 OpenGL 中将 3D 坐标转换为屏幕坐标
- 2D 坐标到 3D 坐标分辨率和相机矩阵
- 2d(3d)坐标的哈希映射(即双精度向量)
- 为openGL提供3D坐标的顺序是什么?
- 如何将屏幕上的鼠标坐标转换为3D坐标
- 在c++中修改3D坐标
- 从3D坐标转换到2D坐标的问题