输入点云没有数据

Input Point Cloud has no data

我应用了RANSAC并成功地从场景中分割出了需要的部分。 问题是当所需的部分长时间不在相机前面时,它会在抛出异常后崩溃。 我怎么可能以最好的方式处理这个异常,因为即使在它一直在寻找它的场景中找不到对象?

[pcl::SampleConsensusModel::getSamples] Can not select 0 unique points out of 0! 
[pcl::RandomSampleConsensus::computeModel] No samples could be selected! 
[pcl::SACSegmentation::segment] Error segmenting the model! No solution found. 
Could not find any points that fitted the model. 
[pcl::KdTreeFLANN::setInputCloud] Cannot create a KDTree with an empty input cloud! 
terminate called after throwing an instance of 'pcl::IOException' 
  what():  : [pcl::PCDWriter::writeASCII] Input point cloud has no data! 
Aborted (core dumped)

在调用写入函数之前检查云的大小。

if(cloud->size() > 0)