Search code examples
c++computer-visionpoint-cloud-libraryroboticsransac

Input Point Cloud has no data


I applied RANSAC and successfully segment out the required part from the scene. The problem is when for a long time the required part is not present infront of the camera it crashes out after throwing an exception. How I could possibly deals with this exception in the best way as even the object is not found in the scene it keeps looking for it ?

[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)

Solution

  • Check the size of the cloud before calling the write function.

    if(cloud->size() > 0)