Point Cloud Library (PCL)
1.6.0
Main Page
Modules
Namespaces
Classes
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
doc
tutorials
content
sources
iccv2011
include
feature_estimation.h
Go to the documentation of this file.
1
#ifndef FEATURE_ESTIMATION_H
2
#define FEATURE_ESTIMATION_H
3
4
#include "
typedefs.h
"
5
6
#include <
pcl/io/io.h
>
7
#include <
pcl/features/normal_3d.h
>
8
#include <
pcl/keypoints/sift_keypoint.h
>
9
#include <
pcl/features/fpfh.h
>
10
#include <
pcl/features/vfh.h
>
11
#include <
pcl/search/kdtree.h
>
12
/* Use NormalEstimation to estimate a cloud's surface normals
13
* Inputs:
14
* input
15
* The input point cloud
16
* radius
17
* The size of the local neighborhood used to estimate the surface
18
* Return: A pointer to a SurfaceNormals point cloud
19
*/
20
SurfaceNormalsPtr
21
estimateSurfaceNormals
(
const
PointCloudPtr
& input,
float
radius)
22
{
23
pcl::NormalEstimation<PointT, NormalT>
normal_estimation;
24
normal_estimation.
setSearchMethod
(
pcl::search::Search<PointT>::Ptr
(
new
pcl::search::KdTree<PointT>
));
25
normal_estimation.
setRadiusSearch
(radius);
26
normal_estimation.
setInputCloud
(input);
27
SurfaceNormalsPtr
normals (
new
SurfaceNormals
);
28
normal_estimation.
compute
(*normals);
29
30
return
(normals);
31
}
32
33
/* Use SIFTKeypoint to detect a set of keypoints
34
* Inputs:
35
* points
36
* The input point cloud
37
* normals
38
* The input surface normals
39
* min_scale
40
* The smallest scale in the difference-of-Gaussians (DoG) scale-space
41
* nr_octaves
42
* The number of times the scale doubles in the DoG scale-space
43
* nr_scales_per_octave
44
* The number of scales computed for each doubling
45
* min_contrast
46
* The minimum local contrast that must be present for a keypoint to be detected
47
* Return: A pointer to a point cloud of keypoints
48
*/
49
PointCloudPtr
50
detectKeypoints
(
const
PointCloudPtr
& points,
const
SurfaceNormalsPtr
& normals,
51
float
min_scale,
int
nr_octaves,
int
nr_scales_per_octave,
float
min_contrast)
52
{
53
pcl::SIFTKeypoint<PointT, pcl::PointWithScale>
sift_detect;
54
sift_detect.
setSearchMethod
(
pcl::search::Search<PointT>::Ptr
(
new
pcl::search::KdTree<PointT>
));
55
sift_detect.
setScales
(min_scale, nr_octaves, nr_scales_per_octave);
56
sift_detect.
setMinimumContrast
(min_contrast);
57
sift_detect.
setInputCloud
(points);
58
pcl::PointCloud<pcl::PointWithScale>
keypoints_temp;
59
sift_detect.
compute
(keypoints_temp);
60
PointCloudPtr
keypoints (
new
PointCloud
);
61
pcl::copyPointCloud
(keypoints_temp, *keypoints);
62
63
return
(keypoints);
64
}
65
66
/* Use FPFHEstimation to compute local feature descriptors around each keypoint
67
* Inputs:
68
* points
69
* The input point cloud
70
* normals
71
* The input surface normals
72
* keypoints
73
* A cloud of keypoints specifying the positions at which the descriptors should be computed
74
* feature_radius
75
* The size of the neighborhood from which the local descriptors will be computed
76
* Return: A pointer to a LocalDescriptors (a cloud of LocalDescriptorT points)
77
*/
78
LocalDescriptorsPtr
79
computeLocalDescriptors
(
const
PointCloudPtr
& points,
const
SurfaceNormalsPtr
& normals,
80
const
PointCloudPtr
& keypoints,
float
feature_radius)
81
{
82
pcl::FPFHEstimation<PointT, NormalT, LocalDescriptorT>
fpfh_estimation;
83
fpfh_estimation.
setSearchMethod
(
pcl::search::Search<PointT>::Ptr
(
new
pcl::search::KdTree<PointT>
));
84
fpfh_estimation.
setRadiusSearch
(feature_radius);
85
fpfh_estimation.
setSearchSurface
(points);
86
fpfh_estimation.
setInputNormals
(normals);
87
fpfh_estimation.
setInputCloud
(keypoints);
88
LocalDescriptorsPtr
local_descriptors (
new
LocalDescriptors
);
89
fpfh_estimation.
compute
(*local_descriptors);
90
91
return
(local_descriptors);
92
}
93
94
/* Use VFHEstimation to compute a single global descriptor for the entire input cloud
95
* Inputs:
96
* points
97
* The input point cloud
98
* normals
99
* The input surface normals
100
* Return: A pointer to a GlobalDescriptors point cloud (a cloud containing a single GlobalDescriptorT point)
101
*/
102
GlobalDescriptorsPtr
103
computeGlobalDescriptor
(
const
PointCloudPtr
& points,
const
SurfaceNormalsPtr
& normals)
104
{
105
pcl::VFHEstimation<PointT, NormalT, GlobalDescriptorT>
vfh_estimation;
106
vfh_estimation.
setSearchMethod
(
pcl::search::Search<PointT>::Ptr
(
new
pcl::search::KdTree<PointT>
));
107
vfh_estimation.
setInputCloud
(points);
108
vfh_estimation.
setInputNormals
(normals);
109
GlobalDescriptorsPtr
global_descriptor (
new
GlobalDescriptors
);
110
vfh_estimation.
compute
(*global_descriptor);
111
112
return
(global_descriptor);
113
}
114
115
/* A simple structure for storing all of a cloud's features */
116
struct
ObjectFeatures
117
{
118
PointCloudPtr
points
;
119
SurfaceNormalsPtr
normals
;
120
PointCloudPtr
keypoints
;
121
LocalDescriptorsPtr
local_descriptors
;
122
GlobalDescriptorsPtr
global_descriptor
;
123
};
124
125
/* Estimate normals, detect keypoints, and compute local and global descriptors
126
* Return: An ObjectFeatures struct containing all the features
127
*/
128
ObjectFeatures
129
computeFeatures
(
const
PointCloudPtr
& input)
130
{
131
ObjectFeatures
features;
132
features.
points
= input;
133
features.
normals
=
estimateSurfaceNormals
(input, 0.05);
134
features.
keypoints
=
detectKeypoints
(input, features.
normals
, 0.005, 10, 8, 1.5);
135
features.
local_descriptors
=
computeLocalDescriptors
(input, features.
normals
, features.
keypoints
, 0.1);
136
features.
global_descriptor
=
computeGlobalDescriptor
(input, features.
normals
);
137
138
return
(features);
139
}
140
141
#endif
Generated on Fri Mar 8 2013 12:50:45 for Point Cloud Library (PCL) by
1.8.3.1