Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
features
impl
narf.hpp
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2010, Willow Garage, Inc.
6
* Copyright (c) 2012-, Open Perception, Inc.
7
*
8
* All rights reserved.
9
*
10
* Redistribution and use in source and binary forms, with or without
11
* modification, are permitted provided that the following conditions
12
* are met:
13
*
14
* * Redistributions of source code must retain the above copyright
15
* notice, this list of conditions and the following disclaimer.
16
* * Redistributions in binary form must reproduce the above
17
* copyright notice, this list of conditions and the following
18
* disclaimer in the documentation and/or other materials provided
19
* with the distribution.
20
* * Neither the name of the copyright holder(s) nor the names of its
21
* contributors may be used to endorse or promote products derived
22
* from this software without specific prior written permission.
23
*
24
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
* POSSIBILITY OF SUCH DAMAGE.
36
*
37
*/
38
39
#include <iostream>
40
#include <
pcl/common/norms.h
>
// for L1_Norm
41
#include <pcl/common/eigen.h>
42
43
namespace
pcl
{
44
45
inline
float
46
Narf::getDescriptorDistance
(
const
Narf
& other)
const
47
{
48
float
ret =
L1_Norm
(
descriptor_
, other.
descriptor_
,
descriptor_size_
);
49
//float ret = Sublinear_Norm(descriptor_, other.descriptor_, descriptor_size_);
50
ret /=
static_cast<
float
>
(
descriptor_size_
);
51
return
(ret);
52
}
53
54
inline
void
Narf::copyToNarf36
(
Narf36
& narf36)
const
55
{
56
if
(
descriptor_size_
!= 36)
57
{
58
std::cerr << __PRETTY_FUNCTION__ <<
": descriptor size is not 36!\n"
;
59
return
;
60
}
61
getTranslationAndEulerAngles
(
transformation_
.inverse (), narf36.
x
, narf36.
y
, narf36.
z
, narf36.
roll
, narf36.
pitch
, narf36.
yaw
);
62
std::copy(
descriptor_
,
descriptor_
+ 36, narf36.
descriptor
);
63
}
64
65
//inline float Narf::getDescriptorDistance(const Narf& other) const
66
//{
67
//float middle_value = 0.1f;
68
//float normalization_factor1 = 1.0f/middle_value,
69
//normalization_factor2 = 1.0f/(1.0f-middle_value);
70
//const float* descriptor1_ptr = descriptor_;
71
//const float* descriptor2_ptr = other.getDescriptor();
72
//float ret = 0;
73
//for (int i=0; i<descriptor_size_; ++i) {
74
//float diff = std::abs(*(descriptor2_ptr++) - *(descriptor1_ptr++));
75
//if (diff < middle_value)
76
//{
77
//diff = diff*normalization_factor1;
78
//diff = 0.5f*diff*diff;
79
////diff = 0.5f*powf(diff, 2);
80
//}
81
//else
82
//{
83
//diff = (diff - middle_value)*normalization_factor2;
84
//diff = 0.5f + 0.5f*diff;
85
////diff = 0.5f + 0.5f*std::sqrt(diff);
86
////diff = 0.5f + 0.5f*powf(diff, 0.3f);
87
//}
88
//ret += diff;
89
//}
90
//ret /= descriptor_size_;
91
//return ret;
92
//}
93
94
//inline float Narf::getDescriptorDistance(const Narf& other) const
95
//{
96
//float max_diff_between_cells = 0.25;
97
98
//const float* descriptor1_ptr = descriptor_;
99
//const float* descriptor2_ptr = other.getDescriptor();
100
//float ret = 0;
101
//for (int i=0; i<descriptor_size_; ++i) {
102
//ret += (std::min)(max_diff_between_cells, std::abs(*(descriptor2_ptr++) - *(descriptor1_ptr++)));
103
//}
104
//ret /= descriptor_size_*max_diff_between_cells;
105
//return ret;
106
//}
107
108
}
// namespace end
pcl::Narf::descriptor_size_
int descriptor_size_
Definition
narf.h:285
pcl::Narf::copyToNarf36
void copyToNarf36(Narf36 &narf36) const
Copy the descriptor and pose to the point struct Narf36.
Definition
narf.hpp:54
pcl::Narf::Narf
Narf()
Constructor.
pcl::Narf::transformation_
Eigen::Affine3f transformation_
Definition
narf.h:279
pcl::Narf::descriptor_
float * descriptor_
Definition
narf.h:284
pcl::Narf::getDescriptorDistance
float getDescriptorDistance(const Narf &other) const
Calculate descriptor distance, value in [0,1] with 0 meaning identical and 1 every cell above maximum...
Definition
narf.hpp:46
pcl::getTranslationAndEulerAngles
void getTranslationAndEulerAngles(const Eigen::Transform< Scalar, 3, Eigen::Affine > &t, Scalar &x, Scalar &y, Scalar &z, Scalar &roll, Scalar &pitch, Scalar &yaw)
Extract x,y,z and the Euler angles (intrinsic rotations, ZYX-convention) from the given transformatio...
Definition
eigen.hpp:604
pcl::L1_Norm
float L1_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the L1 norm of the vector between two points.
Definition
norms.hpp:88
pcl
Definition
convolution.h:46
norms.h
Define standard C methods to calculate different norms.
pcl::Narf36
A point structure representing the Narf descriptor.
Definition
point_types.hpp:1537
pcl::Narf36::roll
float roll
Definition
point_types.hpp:1538
pcl::Narf36::pitch
float pitch
Definition
point_types.hpp:1538
pcl::Narf36::z
float z
Definition
point_types.hpp:1538
pcl::Narf36::y
float y
Definition
point_types.hpp:1538
pcl::Narf36::yaw
float yaw
Definition
point_types.hpp:1538
pcl::Narf36::descriptor
float descriptor[36]
Definition
point_types.hpp:1539
pcl::Narf36::x
float x
Definition
point_types.hpp:1538