Elipsoids.h
Go to the documentation of this file.
00001 // kate: replace-tabs off; indent-width 4; indent-mode normal
00002 // vim: ts=4:sw=4:noexpandtab
00003 /*
00004 
00005 Copyright (c) 2010--2018,
00006 François Pomerleau and Stephane Magnenat, ASL, ETHZ, Switzerland
00007 You can contact the authors at <f dot pomerleau at gmail dot com> and
00008 <stephane at magnenat dot net>
00009 
00010 All rights reserved.
00011 
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided that the following conditions are met:
00014     * Redistributions of source code must retain the above copyright
00015       notice, this list of conditions and the following disclaimer.
00016     * Redistributions in binary form must reproduce the above copyright
00017       notice, this list of conditions and the following disclaimer in the
00018       documentation and/or other materials provided with the distribution.
00019     * Neither the name of the <organization> nor the
00020       names of its contributors may be used to endorse or promote products
00021       derived from this software without specific prior written permission.
00022 
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00024 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00025 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00026 DISCLAIMED. IN NO EVENT SHALL ETH-ASL BE LIABLE FOR ANY
00027 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00028 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00030 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00031 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 */
00035 #pragma once
00036 
00037 #include "PointMatcher.h"
00038 
00040 template<typename T>
00041 struct ElipsoidsDataPointsFilter: public PointMatcher<T>::DataPointsFilter
00042 {
00043         typedef PointMatcherSupport::Parametrizable Parametrizable;
00044         typedef PointMatcherSupport::Parametrizable P;
00045         typedef Parametrizable::Parameters Parameters;
00046         typedef Parametrizable::ParameterDoc ParameterDoc;
00047         typedef Parametrizable::ParametersDoc ParametersDoc;
00048         typedef Parametrizable::InvalidParameter InvalidParameter;
00049         
00050         typedef typename PointMatcher<T>::Vector Vector;
00051         typedef typename PointMatcher<T>::Matrix Matrix;        
00052         typedef typename PointMatcher<T>::DataPoints DataPoints;
00053         typedef typename PointMatcher<T>::DataPoints::InvalidField InvalidField;
00054         
00055   inline static const std::string description()
00056   {
00057     return "Subsampling, Surfels (Elipsoids). This filter decomposes the point-cloud space in boxes, by recursively splitting the cloud through axis-aligned hyperplanes such as to maximize the evenness of the aspect ratio of the box. When the number of points in a box reaches a value knn or lower, the filter computes the center of mass of these points and its normal by taking the eigenvector corresponding to the smallest eigenvalue of all points in the box.";
00058   }
00059   inline static const ParametersDoc availableParameters()
00060   {
00061     return {
00062                 {"ratio", "ratio of points to keep with random subsampling. Matrix (normal, density, etc.) will be associated to all points in the same bin.", "0.5", "0.0000001", "0.9999999", &P::Comp<T> },
00063                 {"knn", "determined how many points are used to compute the normals. Direct link with the rapidity of the computation (large = fast). Technically, limit over which a box is splitted in two", "7", "3", "2147483647", &P::Comp<unsigned> },
00064                 {"samplingMethod", "if set to 0, random subsampling using the parameter ratio. If set to 1, bin subsampling with the resulting number of points being 1/knn.", "0", "0", "1", &P::Comp<unsigned> },
00065                 {"maxBoxDim", "maximum length of a box above which the box is discarded", "inf" },
00066                 {"averageExistingDescriptors", "whether the filter keep the existing point descriptors and average them or should it drop them", "1" },
00067                 {"maxTimeWindow", "maximum spread of times in a surfel", "inf" },
00068                 {"minPlanarity", "to what extend planarity of surfels needs to be enforced", "0"},
00069                 {"keepNormals", "whether the normals should be added as descriptors to the resulting cloud", "1" },
00070                 {"keepDensities", "whether the point densities should be added as descriptors to the resulting cloud", "0" },
00071                 {"keepEigenValues", "whether the eigen values should be added as descriptors to the resulting cloud", "0" },
00072                 {"keepEigenVectors", "whether the eigen vectors should be added as descriptors to the resulting cloud", "0" },
00073                 {"keepMeans", "whether the means should be added as descriptors to the resulting cloud", "0" },
00074                 {"keepCovariances", "whether the covariances should be added as descriptors to the resulting cloud", "0" },
00075                 {"keepWeights", "whether the original number of points should be added as descriptors to the resulting cloud", "0" },
00076                 {"keepShapes", "whether the shape parameters of cylindricity (C), sphericality (S) and planarity (P) shall be calculated", "0" },
00077                 {"keepIndices", "whether the indices of points an ellipsoid is constructed of shall be kept", "0" }
00078     }
00079     ;
00080   }
00081 
00082   const T ratio;
00083   const unsigned knn;
00084   const unsigned samplingMethod;
00085   const T maxBoxDim;
00086   const T maxTimeWindow;
00087   const T minPlanarity;
00088   const bool averageExistingDescriptors;
00089   const bool keepNormals;
00090   const bool keepDensities;
00091   const bool keepEigenValues;
00092   const bool keepEigenVectors;
00093   const bool keepCovariances;
00094   const bool keepWeights;
00095   const bool keepMeans;
00096   const bool keepShapes;
00097   const bool keepIndices;
00098 
00099 
00100  public:
00101   ElipsoidsDataPointsFilter(const Parameters& params = Parameters());
00102   virtual ~ElipsoidsDataPointsFilter() {}
00103   virtual DataPoints filter(const DataPoints& input);
00104   virtual void inPlaceFilter(DataPoints& cloud);
00105 
00106  protected:
00107   struct BuildData
00108   {
00109     typedef std::vector<int> Indices;
00110     typedef typename DataPoints::View View;
00111     typedef typename Eigen::Matrix<std::int64_t, Eigen::Dynamic, Eigen::Dynamic> Int64Matrix;
00112     typedef typename Eigen::Matrix<std::int64_t, 1, Eigen::Dynamic> Int64Vector;
00113 
00114     Indices indices;
00115     Indices indicesToKeep;
00116     Matrix& features;
00117     Matrix& descriptors;
00118     Int64Matrix& times;
00119     boost::optional<View> normals;
00120     boost::optional<View> densities;
00121     boost::optional<View> eigenValues;
00122     boost::optional<View> eigenVectors;
00123     boost::optional<View> weights;
00124     boost::optional<View> covariance;
00125     boost::optional<View> means;
00126     boost::optional<View> shapes;
00127     boost::optional<View> pointIds;
00128     boost::optional<View> pointX;
00129     boost::optional<View> pointY;
00130     boost::optional<View> pointZ;
00131     boost::optional<View> numOfNN;
00132     int outputInsertionPoint;
00133     int unfitPointsCount;
00134 
00135     BuildData(Matrix& features, Matrix& descriptors, Int64Matrix& times):
00136       features(features),
00137       descriptors(descriptors),
00138       times(times),
00139       unfitPointsCount(0)
00140     {
00141       const int pointsCount(features.cols());
00142       indices.reserve(pointsCount);
00143       for (int i = 0; i < pointsCount; ++i)
00144         indices.push_back(i);
00145     }
00146   };
00147 
00148   struct CompareDim
00149   {
00150     const int dim;
00151     const BuildData& buildData;
00152     CompareDim(const int dim, const BuildData& buildData):dim(dim),buildData(buildData){}
00153     bool operator() (const int& p0, const int& p1)
00154     {
00155       return buildData.features(dim, p0) <
00156           buildData.features(dim, p1);
00157     }
00158   };
00159 
00160  protected:
00161   void buildNew(BuildData& data, const int first, const int last, Vector&& minValues, Vector&& maxValues) const;
00162   void fuseRange(BuildData& data, const int first, const int last) const;
00163 };


libpointmatcher
Author(s):
autogenerated on Thu Jun 20 2019 19:51:29