Point Cloud Library (PCL)
1.12.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 pooint 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
, threads_ (1)
85
{
86
name_
=
"TrajkovicKeypoint2D"
;
87
}
88
89
/** \brief set the method of the response to be calculated.
90
* \param[in] method either 4 corners or 8 corners
91
*/
92
inline
void
93
setMethod
(
ComputationMethod
method) { method_ = method; }
94
95
/// \brief \return the computation method
96
inline
ComputationMethod
97
getMethod
()
const
{
return
(method_); }
98
99
/// \brief Set window size
100
inline
void
101
setWindowSize
(
int
window_size) { window_size_= window_size; }
102
103
/// \brief \return window size i.e. window width or height
104
inline
int
105
getWindowSize
()
const
{
return
(window_size_); }
106
107
/** \brief set the first_threshold to reject corners in the simple cornerness
108
* computation stage.
109
* \param[in] threshold
110
*/
111
inline
void
112
setFirstThreshold
(
float
threshold) { first_threshold_= threshold; }
113
114
/// \brief \return first threshold
115
inline
float
116
getFirstThreshold
()
const
{
return
(first_threshold_); }
117
118
/** \brief set the second threshold to reject corners in the final cornerness
119
* computation stage.
120
* \param[in] threshold
121
*/
122
inline
void
123
setSecondThreshold
(
float
threshold) { second_threshold_= threshold; }
124
125
/// \brief \return second threshold
126
inline
float
127
getSecondThreshold
()
const
{
return
(second_threshold_); }
128
129
/** \brief Initialize the scheduler and set the number of threads to use.
130
* \param nr_threads the number of hardware threads to use, 0 for automatic.
131
*/
132
inline
void
133
setNumberOfThreads
(
unsigned
int
nr_threads = 0) { threads_ = nr_threads; }
134
135
/// \brief \return the number of threads
136
inline
unsigned
int
137
getNumberOfThreads
()
const
{
return
(threads_); }
138
139
protected
:
140
bool
141
initCompute
()
override
;
142
143
void
144
detectKeypoints (
PointCloudOut
&output)
override
;
145
146
private
:
147
/// comparator for responses intensity
148
inline
bool
149
greaterCornernessAtIndices (
int
a,
int
b)
const
150
{
151
return
(response_->
points
[a] > response_->
points
[b]);
152
}
153
154
/// computation method
155
ComputationMethod
method_;
156
/// Window size
157
int
window_size_;
158
/// half window size
159
int
half_window_size_;
160
/// intensity field accessor
161
IntensityT intensity_;
162
/// first threshold for quick rejection
163
float
first_threshold_;
164
/// second threshold for corner evaluation
165
float
second_threshold_;
166
/// number of threads to be used
167
unsigned
int
threads_;
168
/// point cloud response
169
pcl::PointCloud<float>::Ptr
response_;
170
};
171
}
172
173
#include <pcl/keypoints/impl/trajkovic_2d.hpp>
pcl::PointCloudOut
pcl::Keypoint< PointInT, PointOutT >::name_
std::string name_
Definition
keypoint.h:169
pcl::Keypoint::PointCloudIn
pcl::PointCloud< PointInT > PointCloudIn
Definition
keypoint.h:66
pcl::Keypoint< PointInT, PointOutT >::keypoints_indices_
pcl::PointIndicesPtr keypoints_indices_
Definition
keypoint.h:193
pcl::Keypoint::PointCloudOut
pcl::PointCloud< PointOutT > PointCloudOut
Definition
keypoint.h:69
pcl::Keypoint< PointInT, PointOutT >::Keypoint
Keypoint()
Definition
keypoint.h:55
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:413
pcl::PointCloud::points
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
Definition
point_cloud.h:395
pcl::TrajkovicKeypoint2D::getNumberOfThreads
unsigned int getNumberOfThreads() const
Definition
trajkovic_2d.h:137
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:123
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:133
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:97
pcl::TrajkovicKeypoint2D::setWindowSize
void setWindowSize(int window_size)
Set window size.
Definition
trajkovic_2d.h:101
pcl::TrajkovicKeypoint2D::getSecondThreshold
float getSecondThreshold() const
Definition
trajkovic_2d.h:127
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:105
pcl::TrajkovicKeypoint2D::getFirstThreshold
float getFirstThreshold() const
Definition
trajkovic_2d.h:116
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:93
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:112
pcl
Definition
convolution.h:46