harris_3d.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2011, Willow Garage, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef PCL_HARRIS_KEYPOINT_3D_H_
#define PCL_HARRIS_KEYPOINT_3D_H_
#include <pcl/keypoints/keypoint.h>
namespace pcl
{
/** \brief HarrisKeypoint3D uses the idea of 2D Harris keypoints, but instead of using image gradients, it uses
* surface normals.
*
* \author Suat Gedikli
* \ingroup keypoints
*/
template <typename PointInT, typename PointOutT, typename NormalT = pcl::Normal>
class HarrisKeypoint3D : public Keypoint<PointInT, PointOutT>
{
public:
typedef boost::shared_ptr<HarrisKeypoint3D<PointInT, PointOutT, NormalT> > Ptr;
typedef boost::shared_ptr<const HarrisKeypoint3D<PointInT, PointOutT, NormalT> > ConstPtr;
typedef typename Keypoint<PointInT, PointOutT>::PointCloudIn PointCloudIn;
typedef typename Keypoint<PointInT, PointOutT>::PointCloudOut PointCloudOut;
typedef typename Keypoint<PointInT, PointOutT>::KdTree KdTree;
typedef typename PointCloudIn::ConstPtr PointCloudInConstPtr;
typedef typename pcl::PointCloud<NormalT> PointCloudN;
typedef typename PointCloudN::Ptr PointCloudNPtr;
typedef typename PointCloudN::ConstPtr PointCloudNConstPtr;
using Keypoint<PointInT, PointOutT>::name_;
using Keypoint<PointInT, PointOutT>::input_;
using Keypoint<PointInT, PointOutT>::indices_;
using Keypoint<PointInT, PointOutT>::surface_;
using Keypoint<PointInT, PointOutT>::tree_;
using Keypoint<PointInT, PointOutT>::k_;
using Keypoint<PointInT, PointOutT>::search_radius_;
using Keypoint<PointInT, PointOutT>::search_parameter_;
using Keypoint<PointInT, PointOutT>::keypoints_indices_;
using Keypoint<PointInT, PointOutT>::initCompute;
using PCLBase<PointInT>::setInputCloud;
typedef enum {HARRIS = 1, NOBLE, LOWE, TOMASI, CURVATURE} ResponseMethod;
/** \brief Constructor
* \param[in] method the method to be used to determine the corner responses
* \param[in] radius the radius for normal estimation as well as for non maxima suppression
* \param[in] threshold the threshold to filter out weak corners
*/
HarrisKeypoint3D (ResponseMethod method = HARRIS, float radius = 0.01f, float threshold = 0.0f)
: threshold_ (threshold)
, refine_ (true)
, nonmax_ (true)
, method_ (method)
, threads_ (0)
{
name_ = "HarrisKeypoint3D";
search_radius_ = radius;
}
/** \brief Empty destructor */
virtual ~HarrisKeypoint3D () {}
/** \brief Provide a pointer to the input dataset
* \param[in] cloud the const boost shared pointer to a PointCloud message
*/
virtual void
setInputCloud (const PointCloudInConstPtr &cloud);
/** \brief Set the method of the response to be calculated.
* \param[in] type
*/
void
setMethod (ResponseMethod type);
/** \brief Set the radius for normal estimation and non maxima supression.
* \param[in] radius
*/
void
setRadius (float radius);
/** \brief Set the threshold value for detecting corners. This is only evaluated if non maxima suppression is turned on.
* \brief note non maxima suppression needs to be activated in order to use this feature.
* \param[in] threshold
*/
void
setThreshold (float threshold);
/** \brief Whether non maxima suppression should be applied or the response for each point should be returned
* \note this value needs to be turned on in order to apply thresholding and refinement
* \param[in] nonmax default is false
*/
void
setNonMaxSupression (bool = false);
/** \brief Whether the detected key points should be refined or not. If turned of, the key points are a subset of the original point cloud. Otherwise the key points may be arbitrary.
* \brief note non maxima supression needs to be on in order to use this feature.
* \param[in] do_refine
*/
void
setRefine (bool do_refine);
/** \brief Set normals if precalculated normals are available.
* \param normals
*/
void
setNormals (const PointCloudNConstPtr &normals);
/** \brief Provide a pointer to a dataset to add additional information
* to estimate the features for every point in the input dataset. This
* is optional, if this is not set, it will only use the data in the
* input cloud to estimate the features. This is useful when you only
* need to compute the features for a downsampled cloud.
* \param[in] cloud a pointer to a PointCloud message
*/
virtual void
setSearchSurface (const PointCloudInConstPtr &cloud) { surface_ = cloud; normals_.reset(); }
/** \brief Initialize the scheduler and set the number of threads to use.
* \param nr_threads the number of hardware threads to use (0 sets the value back to automatic)
*/
inline void
setNumberOfThreads (unsigned int nr_threads = 0) { threads_ = nr_threads; }
protected:
bool
initCompute ();
void detectKeypoints (PointCloudOut &output);
/** \brief gets the corner response for valid input points*/
void responseHarris (PointCloudOut &output) const;
void responseNoble (PointCloudOut &output) const;
void responseLowe (PointCloudOut &output) const;
void responseTomasi (PointCloudOut &output) const;
void responseCurvature (PointCloudOut &output) const;
void refineCorners (PointCloudOut &corners) const;
/** \brief calculates the upper triangular part of unnormalized covariance matrix over the normals given by the indices.*/
void calculateNormalCovar (const std::vector<int>& neighbors, float* coefficients) const;
private:
float threshold_;
bool refine_;
bool nonmax_;
ResponseMethod method_;
PointCloudNConstPtr normals_;
unsigned int threads_;
};
}
#include <pcl/keypoints/impl/harris_3d.hpp>
#endif // #ifndef PCL_HARRIS_KEYPOINT_3D_H_
pcl::HarrisKeypoint3D::Ptr
boost::shared_ptr< HarrisKeypoint3D< PointInT, PointOutT, NormalT > > Ptr
Definition: harris_3d.h:55
pcl::HarrisKeypoint3D::refineCorners
void refineCorners(PointCloudOut &corners) const
Definition: harris_3d.hpp:498
pcl::HarrisKeypoint3D::setRadius
void setRadius(float radius)
Set the radius for normal estimation and non maxima supression.
Definition: harris_3d.hpp:78
pcl::HarrisKeypoint3D::PointCloudIn
Keypoint< PointInT, PointOutT >::PointCloudIn PointCloudIn
Definition: harris_3d.h:58
pcl::HarrisKeypoint3D::setInputCloud
virtual void setInputCloud(const PointCloudInConstPtr &cloud)
Provide a pointer to the input dataset.
Definition: harris_3d.hpp:55
pcl::HarrisKeypoint3D::setNormals
void setNormals(const PointCloudNConstPtr &normals)
Set normals if precalculated normals are available.
Definition: harris_3d.hpp:99
pcl::HarrisKeypoint3D::initCompute
bool initCompute()
Definition: harris_3d.hpp:195
pcl::Keypoint::name_
std::string name_
The key point detection method&#39;s name.
Definition: keypoint.h:173
pcl
Definition: cloud_iterator.h:46
pcl::HarrisKeypoint3D::calculateNormalCovar
void calculateNormalCovar(const std::vector< int > &neighbors, float *coefficients) const
calculates the upper triangular part of unnormalized covariance matrix over the normals given by the ...
Definition: harris_3d.hpp:106
pcl::HarrisKeypoint3D::setSearchSurface
virtual void setSearchSurface(const PointCloudInConstPtr &cloud)
Provide a pointer to a dataset to add additional information to estimate the features for every point...
Definition: harris_3d.h:153
pcl::Keypoint::search_radius_
double search_radius_
The nearest neighbors search radius for each point.
Definition: keypoint.h:191
pcl::HarrisKeypoint3D::setNumberOfThreads
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
Definition: harris_3d.h:159
pcl::HarrisKeypoint3D::setThreshold
void setThreshold(float threshold)
Set the threshold value for detecting corners.
Definition: harris_3d.hpp:71
pcl::HarrisKeypoint3D::HarrisKeypoint3D
HarrisKeypoint3D(ResponseMethod method=HARRIS, float radius=0.01f, float threshold=0.0f)
Constructor.
Definition: harris_3d.h:86
pcl::PointCloud< NormalT >::Ptr
boost::shared_ptr< PointCloud< NormalT > > Ptr
Definition: point_cloud.h:428
pcl::Keypoint
Keypoint represents the base class for key points.
Definition: keypoint.h:55
pcl::HarrisKeypoint3D::TOMASI
Definition: harris_3d.h:79
pcl::HarrisKeypoint3D::NOBLE
Definition: harris_3d.h:79
pcl::HarrisKeypoint3D::PointCloudNConstPtr
PointCloudN::ConstPtr PointCloudNConstPtr
Definition: harris_3d.h:65
pcl::HarrisKeypoint3D::~HarrisKeypoint3D
virtual ~HarrisKeypoint3D()
Empty destructor.
Definition: harris_3d.h:98
pcl::Keypoint::surface_
PointCloudInConstPtr surface_
An input point cloud describing the surface that is to be used for nearest neighbors estimation...
Definition: keypoint.h:182
pcl::HarrisKeypoint3D::CURVATURE
Definition: harris_3d.h:79
pcl::PCLBase
PCL base class.
Definition: pcl_base.h:68
pcl::HarrisKeypoint3D::HARRIS
Definition: harris_3d.h:79
pcl::HarrisKeypoint3D::detectKeypoints
void detectKeypoints(PointCloudOut &output)
Abstract key point detection method.
Definition: harris_3d.hpp:241
pcl::HarrisKeypoint3D::setRefine
void setRefine(bool do_refine)
Whether the detected key points should be refined or not.
Definition: harris_3d.hpp:85
pcl::PointCloud< PointInT >::ConstPtr
boost::shared_ptr< const PointCloud< PointInT > > ConstPtr
Definition: point_cloud.h:429
pcl::PointCloud< PointInT >
pcl::HarrisKeypoint3D::responseTomasi
void responseTomasi(PointCloudOut &output) const
Definition: harris_3d.hpp:455
pcl::HarrisKeypoint3D::PointCloudOut
Keypoint< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition: harris_3d.h:59
pcl::HarrisKeypoint3D::responseHarris
void responseHarris(PointCloudOut &output) const
gets the corner response for valid input points
Definition: harris_3d.hpp:322
pcl::HarrisKeypoint3D::PointCloudInConstPtr
PointCloudIn::ConstPtr PointCloudInConstPtr
Definition: harris_3d.h:61
pcl::HarrisKeypoint3D::setNonMaxSupression
void setNonMaxSupression(bool=false)
Whether non maxima suppression should be applied or the response for each point should be returned...
Definition: harris_3d.hpp:92
pcl::HarrisKeypoint3D::PointCloudN
pcl::PointCloud< NormalT > PointCloudN
Definition: harris_3d.h:63
pcl::HarrisKeypoint3D::setMethod
void setMethod(ResponseMethod type)
Set the method of the response to be calculated.
Definition: harris_3d.hpp:64
pcl::HarrisKeypoint3D::LOWE
Definition: harris_3d.h:79
pcl::HarrisKeypoint3D::PointCloudNPtr
PointCloudN::Ptr PointCloudNPtr
Definition: harris_3d.h:64
pcl::HarrisKeypoint3D
HarrisKeypoint3D uses the idea of 2D Harris keypoints, but instead of using image gradients...
Definition: harris_3d.h:52
pcl::HarrisKeypoint3D::ResponseMethod
ResponseMethod
Definition: harris_3d.h:79
pcl::HarrisKeypoint3D::responseCurvature
void responseCurvature(PointCloudOut &output) const
Definition: harris_3d.hpp:437
pcl::HarrisKeypoint3D::KdTree
Keypoint< PointInT, PointOutT >::KdTree KdTree
Definition: harris_3d.h:60
pcl::HarrisKeypoint3D::responseLowe
void responseLowe(PointCloudOut &output) const
Definition: harris_3d.hpp:399
pcl::HarrisKeypoint3D::responseNoble
void responseNoble(PointCloudOut &output) const
Definition: harris_3d.hpp:361
pcl::HarrisKeypoint3D::ConstPtr
boost::shared_ptr< const HarrisKeypoint3D< PointInT, PointOutT, NormalT > > ConstPtr
Definition: harris_3d.h:56
pcl::search::Search< PointInT >