Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
keypoints
trajkovic_2d.h
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2013-, Open Perception Inc.
6
*
7
* All rights reserved.
8
*
9
* Redistribution and use in source and binary forms, with or without
10
* modification, are permitted provided that the following conditions
11
* are met:
12
*
13
* * Redistributions of source code must retain the above copyright
14
* notice, this list of conditions and the following disclaimer.
15
* * Redistributions in binary form must reproduce the above
16
* copyright notice, this list of conditions and the following
17
* disclaimer in the documentation and/or other materials provided
18
* with the distribution.
19
* * Neither the name of Willow Garage, Inc. nor the names of its
20
* contributors may be used to endorse or promote products derived
21
* from this software without specific prior written permission.
22
*
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
* POSSIBILITY OF SUCH DAMAGE.
35
*
36
*/
37
38
#pragma once
39
40
#include <pcl/keypoints/keypoint.h>
41
#include <pcl/common/intensity.h>
42
43
namespace
pcl
44
{
45
/** \brief TrajkovicKeypoint2D implements Trajkovic and Hedley corner detector on
46
* organized point cloud using intensity information.
47
* It uses first order statistics to find variation of intensities in horizontal
48
* or vertical directions.
49
*
50
* \author Nizar Sallem
51
* \ingroup keypoints
52
*/
53
template
<
typename
Po
int
InT,
typename
Po
int
OutT,
typename
IntensityT = pcl::common::IntensityFieldAccessor<Po
int
InT> >
54
class
TrajkovicKeypoint2D
:
public
Keypoint
<PointInT, PointOutT>
55
{
56
public
:
57
using
Ptr
= shared_ptr<TrajkovicKeypoint2D<PointInT, PointOutT, IntensityT> >;
58
using
ConstPtr
= shared_ptr<const TrajkovicKeypoint2D<PointInT, PointOutT, IntensityT> >;
59
using
PointCloudIn
=
typename
Keypoint<PointInT, PointOutT>::PointCloudIn
;
60
using
PointCloudOut
=
typename
Keypoint<PointInT, PointOutT>::PointCloudOut
;
61
using
PointCloudInConstPtr
=
typename
PointCloudIn::ConstPtr;
62
63
using
Keypoint
<PointInT, PointOutT>
::name_
;
64
using
Keypoint
<PointInT, PointOutT>
::input_
;
65
using
Keypoint
<PointInT, PointOutT>
::indices_
;
66
using
Keypoint
<PointInT, PointOutT>
::keypoints_indices_
;
67
68
enum
ComputationMethod
{
FOUR_CORNERS
,
EIGHT_CORNERS
};
69
70
/** \brief Constructor
71
* \param[in] method the method to be used to determine the corner responses
72
* \param[in] window_size
73
* \param[in] first_threshold the threshold used in the simple cornerness test.
74
* \param[in] second_threshold the threshold used to reject weak corners.
75
*/
76
TrajkovicKeypoint2D
(
ComputationMethod
method =
FOUR_CORNERS
,
77
int
window_size = 3,
78
float
first_threshold = 0.1,
79
float
second_threshold = 100.0)
80
: method_ (method)
81
, window_size_ (window_size)
82
, first_threshold_ (first_threshold)
83
, second_threshold_ (second_threshold)
84
{
85
name_
=
"TrajkovicKeypoint2D"
;
86
}
87
88
/** \brief set the method of the response to be calculated.
89
* \param[in] method either 4 corners or 8 corners
90
*/
91
inline
void
92
setMethod
(
ComputationMethod
method) { method_ = method; }
93
94
/// \brief \return the computation method
95
inline
ComputationMethod
96
getMethod
()
const
{
return
(method_); }
97
98
/// \brief Set window size
99
inline
void
100
setWindowSize
(
int
window_size) { window_size_= window_size; }
101
102
/// \brief \return window size i.e. window width or height
103
inline
int
104
getWindowSize
()
const
{
return
(window_size_); }
105
106
/** \brief set the first_threshold to reject corners in the simple cornerness
107
* computation stage.
108
* \param[in] threshold
109
*/
110
inline
void
111
setFirstThreshold
(
float
threshold) { first_threshold_= threshold; }
112
113
/// \brief \return first threshold
114
inline
float
115
getFirstThreshold
()
const
{
return
(first_threshold_); }
116
117
/** \brief set the second threshold to reject corners in the final cornerness
118
* computation stage.
119
* \param[in] threshold
120
*/
121
inline
void
122
setSecondThreshold
(
float
threshold) { second_threshold_= threshold; }
123
124
/// \brief \return second threshold
125
inline
float
126
getSecondThreshold
()
const
{
return
(second_threshold_); }
127
128
/** \brief Initialize the scheduler and set the number of threads to use.
129
* \param nr_threads the number of hardware threads to use, 0 for automatic.
130
*/
131
inline
void
132
setNumberOfThreads
(
unsigned
int
nr_threads = 0) { threads_ = nr_threads; }
133
134
/// \brief \return the number of threads
135
inline
unsigned
int
136
getNumberOfThreads
()
const
{
return
(threads_); }
137
138
protected
:
139
bool
140
initCompute
()
override
;
141
142
void
143
detectKeypoints
(
PointCloudOut
&output)
override
;
144
145
private
:
146
/// comparator for responses intensity
147
inline
bool
148
greaterCornernessAtIndices (
int
a,
int
b)
const
149
{
150
return
(response_->
points
[a] > response_->
points
[b]);
151
}
152
153
/// computation method
154
ComputationMethod
method_;
155
/// Window size
156
int
window_size_;
157
/// half window size
158
int
half_window_size_;
159
/// intensity field accessor
160
IntensityT intensity_;
161
/// first threshold for quick rejection
162
float
first_threshold_;
163
/// second threshold for corner evaluation
164
float
second_threshold_;
165
/// number of threads to be used
166
unsigned
int
threads_{1};
167
/// point cloud response
168
pcl::PointCloud<float>::Ptr
response_;
169
};
170
}
171
172
#include <pcl/keypoints/impl/trajkovic_2d.hpp>
pcl::PointCloudOut
pcl::Keypoint< PointInT, PointOutT >::Keypoint
Keypoint()=default
pcl::Keypoint< PointInT, PointOutT >::name_
std::string name_
Definition
keypoint.h:167
pcl::Keypoint::PointCloudIn
pcl::PointCloud< PointInT > PointCloudIn
Definition
keypoint.h:66
pcl::Keypoint< PointInT, PointOutT >::keypoints_indices_
pcl::PointIndicesPtr keypoints_indices_
Definition
keypoint.h:191
pcl::Keypoint::PointCloudOut
pcl::PointCloud< PointOutT > PointCloudOut
Definition
keypoint.h:69
pcl::PCLBase< PointInT >::input_
PointCloudConstPtr input_
Definition
pcl_base.h:147
pcl::PCLBase< PointInT >::indices_
IndicesPtr indices_
Definition
pcl_base.h:150
pcl::PointCloud::Ptr
shared_ptr< PointCloud< PointT > > Ptr
Definition
point_cloud.h:414
pcl::PointCloud::points
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
Definition
point_cloud.h:396
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
Abstract key point detection method.
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