Changeset 64:b2236a4438f1 in rrlib_model_fitting


Ignore:
Timestamp:
05.05.2017 16:59:19 (4 years ago)
Author:
Tobias Föhst <tobias.foehst@…>
Branch:
17.03
Phase:
public
Message:

Adds error handling for invalid data to ICP algorithm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tIterativeClosestPoint.hpp

    r63 r64  
    160160  data(data_begin, data_end) 
    161161{ 
    162   this->DoICP(sufficient_improvement_threshold, max_iterations); 
     162  if (!this->DoICP(sufficient_improvement_threshold, max_iterations)) 
     163  { 
     164    throw util::tTraceableException<std::runtime_error>("Could not run ICP algorithm."); 
     165  } 
    163166} 
    164167 
     
    199202//---------------------------------------------------------------------- 
    200203template <size_t Tdimension> 
    201 void tIterativeClosestPoint<Tdimension>::DoICP(double sufficient_improvement_threshold, unsigned int max_iterations) 
    202 { 
     204bool tIterativeClosestPoint<Tdimension>::DoICP(double sufficient_improvement_threshold, unsigned int max_iterations) 
     205{ 
     206  if (this->model.empty() || this->data.empty()) 
     207  { 
     208    RRLIB_LOG_PRINT(ERROR, "ICP called on empty point set"); 
     209    return false; 
     210  } 
     211 
    203212  assert(this->model.size() >= 2 && this->data.size() >= 2); 
    204213#ifdef RRLIB_MODEL_FITTING_DEBUG_ICP 
     
    275284  window.Render(); 
    276285#endif 
     286 
     287  return true; 
    277288} 
    278289 
     
    345356void tIterativeClosestPoint<Tdimension>::FindCorrespondencePairs(std::vector<double> &distances, const std::vector<tSample> &model) 
    346357{ 
     358  assert(!(model.empty() || this->data.empty())); 
    347359  this->correspondence_pairs.clear(); 
    348360  distances.clear(); 
     
    371383void tIterativeClosestPoint<Tdimension>::FilterCorrespondencePairs(std::vector<double> &distances) 
    372384{ 
     385  assert(distances.size() == this->correspondence_pairs.size()); 
    373386  std::vector<std::pair<size_t, size_t>> filtered_correspondence_pairs; 
    374387  std::vector<double> filtered_distances; 
Note: See TracChangeset for help on using the changeset viewer.