简体   繁体   English

检测导入点云是否出错,并在不关闭应用PCL和C++的情况下显示提示信息

[英]Detect if there is an error when importing a point cloud and display alert message without closing application PCL and C++

I am trying to import a point cloud into a program I have made with the PCL and C++ library.我正在尝试将点云导入到我使用 PCL 和 C++ 库制作的程序中。 This program must be able to load different files and that, in case of encountering one that has some error at the time of having made its coding, it indicates that there has been an error but in no case makes the application break.该程序必须能够加载不同的文件,并且如果在编写代码时遇到有错误的文件,则表明存在错误但绝不会导致应用程序中断。

The header of a point cloud that right now is causing the program to break is as follows.现在导致程序中断的点云 header 如下所示。

ply
format ascii 1.0
comment PCL generated
element vertex 88655
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
element face 0
element camera 1
property float view_px
property float view_py
property float view_pz
property float x_axisx
property float x_axisy
property float x_axisz
property float y_axisx
property float y_axisy
property float y_axisz
property float z_axisx
property float z_axisy
property float z_axisz
property float focal
property float scalex
property float scaley
property float centerx
property float centery
property int viewportx
property int viewporty
property float k1
property float k2
end_header

And I'm trying to import the cloud as pcl::PointCloud<pcl::PointXYXRGB> and also as a pcl::PolygonMesh .我正在尝试将云导入为pcl::PointCloud<pcl::PointXYXRGB>以及pcl::PolygonMesh In this case, the cloud does not have mesh information but as far as I was noticing with other clouds, the system is able to detect it and import it without any problem.在这种情况下,云没有网格信息,但据我注意到其他云,系统能够检测到它并毫无问题地导入它。

The code I'm using to import the files is:我用来导入文件的代码是:

std::string filepath = "cloud.ply";
// Load cloud
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
pcl::PolygonMesh::Ptr cloud_mesh (new pcl::PolygonMesh);

if (pcl::io::loadPLYFile(filepath_cloud, *cloud) == -1) {
  std::cerr << "Error reading cloud" << std::endl;
}
std::cout << "Reading cloud OK" << std::endl;

if (pcl::io::loadPolygonFilePLY(filepath_cloud, * cloud_mesh) == -1) {
  std::cerr << "Error reading cloud mesh" << std::endl;
}
std::cout << "Reading cloud mesh OK" << std::endl;

Whith this code I obtain these messages until the application crush:通过这段代码,我获得了这些消息,直到应用程序崩溃:

[pcl::PLYReader] C:/Users/Ale/Documents/tmp/cloud.ply:25: property 'float32 focal' of element 'camera' is not handled
[pcl::PLYReader] C:/Users/Ale/Documents/tmp/cloud.ply:26: property 'float32 scalex' of element 'camera' is not handled
[pcl::PLYReader] C:/Users/Ale/Documents/tmp/cloud.ply:27: property 'float32 scaley' of element 'camera' is not handled
[pcl::PLYReader] C:/Users/Ale/Documents/tmp/cloud.ply:28: property 'float32 centerx' of element 'camera' is not handled
[pcl::PLYReader] C:/Users/Ale/Documents/tmp/cloud.ply:29: property 'float32 centery' of element 'camera' is not handled
[pcl::PLYReader] C:/Users/Ale/Documents/tmp/cloud.ply: property 'float32 k1' of element 'camera' is not handled
[pcl::PLYReader] C:/Users/Ale/Documents/tmp/cloud.ply: property 'float32 k2' of element 'camera' is not handled
Reading cloud OK
Warning:  Can't find property 'vertex_indices' in element 'face'

So, what you can see is that, until the time comes to import it to pcl::PolygonMesh , no error occurs.因此,您可以看到,在将其导入pcl::PolygonMesh之前,不会发生任何错误。 What I want to manage is that, although it is not possible to be read as polygonmesh , the application does not close.我要管理的是,虽然不可能被读取为polygonmesh ,但应用程序不会关闭。 In other words, to put the reading of pcl::PolygonMesh in a kind of try{} catch{} so that it simply reads the file if possible.换句话说,将pcl::PolygonMesh的读取放在一种try{} catch{}中,以便它尽可能简单地读取文件。 But I don't know if that can be done or what, if it can be done, how it would have to be done.但我不知道这是否可以完成,或者如果可以完成,又该如何完成。

Try pcl::io::loadPLYFile() ( https://pointclouds.org/documentation/group__io.html#ga0cfc645cc531647728e16088b6342204 ) instead of pcl::io::loadPolygonFilePLY()尝试pcl::io::loadPLYFile() ( https://pointclouds.org/documentation/group__io.html#ga0cfc645cc531647728e16088b6342204 ) 而不是pcl::io::loadPolygonFilePLY()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何确定 C++ 代码中的 PCL(点云库)版本? - How to determine PCL (Point Cloud Library) version in C++ code? 在 c++ 中通过 tcp 发送 pcl 点云 - send pcl point cloud over tcp in c++ C ++中的点云库(PCL)等待/延迟/睡眠功能 - Point Cloud Library (PCL) wait/delay/sleep function in C++ 如何从 std::vector 创建 pcl::PointIndices<int> 在 c++ 中使用 `pcl`(点云库)?</int> - How to create pcl::PointIndices from std::vector<int> with `pcl`(Point Cloud Library) in c++? 我可以在 C++ 中使用 PCL 将无组织的点云数据转换为有组织的点云数据吗? - Can I convert unorganized point cloud data to organized point cloud data using PCL in C++? C++ 点云库 PCL。 尝试添加两点 - C++ Point Cloud Library PCL. Try to add two points VSCode C++ IntelliSense 工作正常,除了 PCL(点云库) - VSCode C++ IntelliSense works fine except for PCL (Point Cloud Library) 如何在保持其顺序的同时对点云进行下采样? (PCL C++) - How to downsample a point cloud while maintaining its order? (PCL C++) c ++ pcl_ros:如何使用最新的100条消息生成点云 - c++ pcl_ros: How to generate point cloud with latest 100 messages JNI_CreateJavaVM使C ++应用程序崩溃而没有错误消息 - JNI_CreateJavaVM crashes C++ application without error message
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM