Loading...
Searching...
No Matches
trajkovic_2d.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2013-, Open Perception 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.
*
*/
#pragma once
#include <pcl/keypoints/keypoint.h>
#include <pcl/common/intensity.h>
namespace pcl
{
/** \brief TrajkovicKeypoint2D implements Trajkovic and Hedley corner detector on
* organized point cloud using intensity information.
* It uses first order statistics to find variation of intensities in horizontal
* or vertical directions.
*
* \author Nizar Sallem
* \ingroup keypoints
*/
template <typename PointInT, typename PointOutT, typename IntensityT = pcl::common::IntensityFieldAccessor<PointInT> >
class TrajkovicKeypoint2D : public Keypoint<PointInT, PointOutT>
{
public:
using Ptr = shared_ptr<TrajkovicKeypoint2D<PointInT, PointOutT, IntensityT> >;
using ConstPtr = shared_ptr<const TrajkovicKeypoint2D<PointInT, PointOutT, IntensityT> >;
using PointCloudIn = typename Keypoint<PointInT, PointOutT>::PointCloudIn;
using PointCloudOut = typename Keypoint<PointInT, PointOutT>::PointCloudOut;
using PointCloudInConstPtr = typename PointCloudIn::ConstPtr;
using Keypoint<PointInT, PointOutT>::name_;
using Keypoint<PointInT, PointOutT>::input_;
using Keypoint<PointInT, PointOutT>::indices_;
using Keypoint<PointInT, PointOutT>::keypoints_indices_;
enum ComputationMethod { FOUR_CORNERS, EIGHT_CORNERS };
/** \brief Constructor
* \param[in] method the method to be used to determine the corner responses
* \param[in] window_size
* \param[in] first_threshold the threshold used in the simple cornerness test.
* \param[in] second_threshold the threshold used to reject weak corners.
*/
TrajkovicKeypoint2D (ComputationMethod method = FOUR_CORNERS,
int window_size = 3,
float first_threshold = 0.1,
float second_threshold = 100.0)
: method_ (method)
, window_size_ (window_size)
, first_threshold_ (first_threshold)
, second_threshold_ (second_threshold)
{
name_ = "TrajkovicKeypoint2D";
}
/** \brief set the method of the response to be calculated.
* \param[in] method either 4 corners or 8 corners
*/
inline void
setMethod (ComputationMethod method) { method_ = method; }
/// \brief \return the computation method
inline ComputationMethod
getMethod () const { return (method_); }
/// \brief Set window size
inline void
setWindowSize (int window_size) { window_size_= window_size; }
/// \brief \return window size i.e. window width or height
inline int
getWindowSize () const { return (window_size_); }
/** \brief set the first_threshold to reject corners in the simple cornerness
* computation stage.
* \param[in] threshold
*/
inline void
setFirstThreshold (float threshold) { first_threshold_= threshold; }
/// \brief \return first threshold
inline float
getFirstThreshold () const { return (first_threshold_); }
/** \brief set the second threshold to reject corners in the final cornerness
* computation stage.
* \param[in] threshold
*/
inline void
setSecondThreshold (float threshold) { second_threshold_= threshold; }
/// \brief \return second threshold
inline float
getSecondThreshold () const { return (second_threshold_); }
/** \brief Initialize the scheduler and set the number of threads to use.
* \param nr_threads the number of hardware threads to use, 0 for automatic.
*/
inline void
setNumberOfThreads (unsigned int nr_threads = 0) { threads_ = nr_threads; }
/// \brief \return the number of threads
inline unsigned int
getNumberOfThreads () const { return (threads_); }
protected:
bool
initCompute () override;
void
detectKeypoints (PointCloudOut &output) override;
private:
/// comparator for responses intensity
inline bool
greaterCornernessAtIndices (int a, int b) const
{
return (response_->points [a] > response_->points [b]);
}
/// computation method
ComputationMethod method_;
/// Window size
int window_size_;
/// half window size
int half_window_size_;
/// intensity field accessor
IntensityT intensity_;
/// first threshold for quick rejection
float first_threshold_;
/// second threshold for corner evaluation
float second_threshold_;
/// number of threads to be used
unsigned int threads_{1};
/// point cloud response
pcl::PointCloud<float>::Ptr response_;
};
}
#include <pcl/keypoints/impl/trajkovic_2d.hpp>
pcl::Keypoint
Keypoint represents the base class for key points.
Definition keypoint.h:49
pcl::Keypoint< PointInT, PointOutT >::name_
std::string name_
The key point detection method's name.
Definition keypoint.h:167
pcl::Keypoint< PointInT, PointOutT >::keypoints_indices_
pcl::PointIndicesPtr keypoints_indices_
Indices of the keypoints in the input cloud.
Definition keypoint.h:191
pcl::PCLBase< PointInT >::input_
PointCloudConstPtr input_
The input point cloud dataset.
Definition pcl_base.h:147
pcl::PCLBase< PointInT >::indices_
IndicesPtr indices_
A pointer to the vector of point indices to use.
Definition pcl_base.h:150
pcl::PointCloud< PointInT >
pcl::PointCloud::Ptr
shared_ptr< PointCloud< PointT > > Ptr
Definition point_cloud.h:413
pcl::PointCloud::points
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
Definition point_cloud.h:395
pcl::TrajkovicKeypoint2D
TrajkovicKeypoint2D implements Trajkovic and Hedley corner detector on organized point cloud using in...
Definition trajkovic_2d.h:55
pcl::TrajkovicKeypoint2D::getNumberOfThreads
unsigned int getNumberOfThreads() const
Definition trajkovic_2d.h:136
pcl::TrajkovicKeypoint2D::PointCloudOut
typename Keypoint< PointInT, PointOutT >::PointCloudOut PointCloudOut
Definition trajkovic_2d.h:60
pcl::TrajkovicKeypoint2D::setSecondThreshold
void setSecondThreshold(float threshold)
set the second threshold to reject corners in the final cornerness computation stage.
Definition trajkovic_2d.h:122
pcl::TrajkovicKeypoint2D::setNumberOfThreads
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
Definition trajkovic_2d.h:132
pcl::TrajkovicKeypoint2D::TrajkovicKeypoint2D
TrajkovicKeypoint2D(ComputationMethod method=FOUR_CORNERS, int window_size=3, float first_threshold=0.1, float second_threshold=100.0)
Constructor.
Definition trajkovic_2d.h:76
pcl::TrajkovicKeypoint2D::getMethod
ComputationMethod getMethod() const
Definition trajkovic_2d.h:96
pcl::TrajkovicKeypoint2D::detectKeypoints
void detectKeypoints(PointCloudOut &output) override
Definition trajkovic_2d.hpp:86
pcl::TrajkovicKeypoint2D::setWindowSize
void setWindowSize(int window_size)
Set window size.
Definition trajkovic_2d.h:100
pcl::TrajkovicKeypoint2D::getSecondThreshold
float getSecondThreshold() const
Definition trajkovic_2d.h:126
pcl::TrajkovicKeypoint2D::ConstPtr
shared_ptr< const TrajkovicKeypoint2D< PointInT, PointOutT, IntensityT > > ConstPtr
Definition trajkovic_2d.h:58
pcl::TrajkovicKeypoint2D::PointCloudInConstPtr
typename PointCloudIn::ConstPtr PointCloudInConstPtr
Definition trajkovic_2d.h:61
pcl::TrajkovicKeypoint2D::getWindowSize
int getWindowSize() const
Definition trajkovic_2d.h:104
pcl::TrajkovicKeypoint2D::getFirstThreshold
float getFirstThreshold() const
Definition trajkovic_2d.h:115
pcl::TrajkovicKeypoint2D::initCompute
bool initCompute() override
Definition trajkovic_2d.hpp:47
pcl::TrajkovicKeypoint2D::ComputationMethod
ComputationMethod
Definition trajkovic_2d.h:68
pcl::TrajkovicKeypoint2D::EIGHT_CORNERS
@ EIGHT_CORNERS
Definition trajkovic_2d.h:68
pcl::TrajkovicKeypoint2D::FOUR_CORNERS
@ FOUR_CORNERS
Definition trajkovic_2d.h:68
pcl::TrajkovicKeypoint2D::setMethod
void setMethod(ComputationMethod method)
set the method of the response to be calculated.
Definition trajkovic_2d.h:92
pcl::TrajkovicKeypoint2D::Ptr
shared_ptr< TrajkovicKeypoint2D< PointInT, PointOutT, IntensityT > > Ptr
Definition trajkovic_2d.h:57
pcl::TrajkovicKeypoint2D::PointCloudIn
typename Keypoint< PointInT, PointOutT >::PointCloudIn PointCloudIn
Definition trajkovic_2d.h:59
pcl::TrajkovicKeypoint2D::setFirstThreshold
void setFirstThreshold(float threshold)
set the first_threshold to reject corners in the simple cornerness computation stage.
Definition trajkovic_2d.h:111
pcl
Definition convolution.h:46