RobWorkProject  23.9.11-
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
StructuredLineModel Class Reference

A model for points placed along a line with regular intervals. More...

#include <StructuredLineModel.hpp>

Inherits RANSACModel< StructuredLineModel, rw::math::Vector3D<> >.

Public Types

typedef rw::core::Ptr< StructuredLineModelPtr
 Smart pointer type to this class.
 
- Public Types inherited from RANSACModel< StructuredLineModel, rw::math::Vector3D<> >
typedef rw::core::Ptr< RANSACModel< StructuredLineModel, rw::math::Vector3D<> > > Ptr
 Smart pointer type to this class.
 

Public Member Functions

 StructuredLineModel ()
 Constructor.
 
 StructuredLineModel (const rw::geometry::Line &line, const rw::math::Vector3D<> &start, double interval)
 Constructor.
 
virtual ~StructuredLineModel ()
 Destructor.
 
virtual double fitError (const rw::math::Vector3D<> &sample) const
 Calculates the fitting error of a sample. More...
 
virtual bool invalid () const
 Checks whether the model is invalid. More...
 
virtual int getMinReqData () const
 Returns the number of samples required to create the model. More...
 
virtual double refit (const std::vector< rw::math::Vector3D<>> &samples)
 Recalculates the model based on provided samples. More...
 
virtual bool same (const StructuredLineModel &model, double threshold) const
 Tests whether the model is same to a threshold of another model. More...
 
double testInterval (const std::vector< rw::math::Vector3D<>> &samples, double interval, rw::math::Vector3D<> start, double maxDist) const
 Test if interval matches the dataset. More...
 
rw::geometry::Line line () const
 Get line.
 
rw::math::Vector3D start () const
 Get starting point.
 
double getInterval () const
 Get interval.
 
- Public Member Functions inherited from RANSACModel< StructuredLineModel, rw::math::Vector3D<> >
 RANSACModel ()
 Constructor.
 
virtual StructuredLineModel make (const std::vector< rw::math::Vector3D<> > &data) const
 Creates a new model of this type using provided data.
 
virtual ~RANSACModel ()
 Destructor.
 
bool operator< (const StructuredLineModel &model) const
 'Worse than' operator. More...
 
bool operator> (const StructuredLineModel &model) const
 'Better than' operator. More...
 
virtual bool belongsTo (const rw::math::Vector3D<> &sample, double threshold) const
 Check whether a sample belongs to the model. More...
 
virtual double refit (const std::vector< rw::math::Vector3D<> > &data)=0
 Recalculates the model based on provided samples. More...
 
size_t getNumberOfInliers () const
 Get the number of inliers.
 
double getQuality () const
 Get the model quality. More...
 
void setQuality (double quality)
 Set the model quality. More...
 
std::vector< rw::math::Vector3D<> > & getData ()
 Access data.
 
const std::vector< rw::math::Vector3D<> > & getData () const
 Access data.
 
std::vector< size_t > getInlierIndices () const
 Get the vector of inlier indices. More...
 

Protected Attributes

rw::geometry::Line _line
 
rw::math::Vector3D _start
 
double _interval
 
- Protected Attributes inherited from RANSACModel< StructuredLineModel, rw::math::Vector3D<> >
std::vector< rw::math::Vector3D<> > _data
 
double _quality
 
std::vector< size_t > _indices
 

Friends

std::ostream & operator<< (std::ostream &out, const StructuredLineModel &model)
 Streaming operator.
 

Additional Inherited Members

- Static Public Member Functions inherited from RANSACModel< StructuredLineModel, rw::math::Vector3D<> >
static std::vector< StructuredLineModelfindModels (const std::vector< rw::math::Vector3D<> > &data, int maxIterations, int dataRequired, double dataThreshold, double modelThreshold)
 Find models fitting a set of observations. More...
 
static StructuredLineModel bestModel (const std::vector< StructuredLineModel > &models)
 Select the model with the largest number of inliers. More...
 
static StructuredLineModel likelyModel (const std::vector< StructuredLineModel > &models)
 Select a model randomly, with a chance based on the number of inliers. More...
 

Detailed Description

A model for points placed along a line with regular intervals.

Structured line is defined using a line in 3D, a starting point which is chosen as the data point with lowest (x+y+z) value, and an interval.

Structured line model requires at least two samples to create.

Member Function Documentation

◆ fitError()

virtual double fitError ( const rw::math::Vector3D<> &  sample) const
virtual

Calculates the fitting error of a sample.

Implements RANSACModel< StructuredLineModel, rw::math::Vector3D<> >.

◆ getMinReqData()

virtual int getMinReqData ( ) const
inlinevirtual

Returns the number of samples required to create the model.

No model will be found, if data size is less than this amount.

StructuredLineModel requires at least 2 sample.

Implements RANSACModel< StructuredLineModel, rw::math::Vector3D<> >.

◆ invalid()

virtual bool invalid ( ) const
virtual

Checks whether the model is invalid.

Implements RANSACModel< StructuredLineModel, rw::math::Vector3D<> >.

◆ refit()

virtual double refit ( const std::vector< rw::math::Vector3D<>> &  samples)
virtual

Recalculates the model based on provided samples.

Returns
Fit error on a set of provided samples.

◆ same()

virtual bool same ( const StructuredLineModel model,
double  threshold 
) const
virtual

Tests whether the model is same to a threshold of another model.

This is used to filter down (merge) similar models found in the course of RANSAC algorithm execution.

Todo:
Include interval difference

StructuredLineModels are the same when the distance between them, according to metric taking into account weighted sum of direction angle difference and the closest separation between lines is lower than specified threshold.

Implements RANSACModel< StructuredLineModel, rw::math::Vector3D<> >.

◆ testInterval()

double testInterval ( const std::vector< rw::math::Vector3D<>> &  samples,
double  interval,
rw::math::Vector3D<>  start,
double  maxDist 
) const

Test if interval matches the dataset.

This is used to find the interval value for the model when refitting. Returns the total error associated with given interval. We want to minimize this function, trying a range of possible intervals. The procedure is as follows:

  1. Find all grid spots on a line between the most outlying samples for a given interval.
  2. For all grid spots find the samples that are closer to it, than they are to any other spot.
  3. If there are no such samples, use the closest one.
  4. For each of the spots calculate cumulated distance to the neighbours.
  5. Total error is the sum of spot errors.

The documentation for this class was generated from the following file: