Point Cloud Library (PCL)
1.7.1
Main Page
Modules
Namespaces
Classes
features
include
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 <map>
41
42
namespace
pcl {
43
44
inline
float
45
Narf::getDescriptorDistance
(
const
Narf
& other)
const
46
{
47
float
ret =
L1_Norm
(
descriptor_
, other.
descriptor_
,
descriptor_size_
);
48
//float ret = Sublinear_Norm(descriptor_, other.descriptor_, descriptor_size_);
49
ret /=
static_cast<
float
>
(
descriptor_size_
);
50
return
(ret);
51
}
52
53
inline
void
Narf::copyToNarf36
(
Narf36
& narf36)
const
54
{
55
if
(
descriptor_size_
!= 36)
56
{
57
std::cerr << __PRETTY_FUNCTION__ <<
": descriptor size is not 36!\n"
;
58
return
;
59
}
60
getTranslationAndEulerAngles
(
transformation_
.inverse (), narf36.
x
, narf36.
y
, narf36.
z
, narf36.
roll
, narf36.
pitch
, narf36.
yaw
);
61
memcpy(narf36.
descriptor
,
descriptor_
, 36*
sizeof
(*
descriptor_
));
62
}
63
64
//inline float Narf::getDescriptorDistance(const Narf& other) const
65
//{
66
//float middle_value = 0.1f;
67
//float normalization_factor1 = 1.0f/middle_value,
68
//normalization_factor2 = 1.0f/(1.0f-middle_value);
69
//const float* descriptor1_ptr = descriptor_;
70
//const float* descriptor2_ptr = other.getDescriptor();
71
//float ret = 0;
72
//for (int i=0; i<descriptor_size_; ++i) {
73
//float diff = fabsf(*(descriptor2_ptr++) - *(descriptor1_ptr++));
74
//if (diff < middle_value)
75
//{
76
//diff = diff*normalization_factor1;
77
//diff = 0.5f*diff*diff;
78
////diff = 0.5f*powf(diff, 2);
79
//}
80
//else
81
//{
82
//diff = (diff - middle_value)*normalization_factor2;
83
//diff = 0.5f + 0.5f*diff;
84
////diff = 0.5f + 0.5f*sqrtf(diff);
85
////diff = 0.5f + 0.5f*powf(diff, 0.3f);
86
//}
87
//ret += diff;
88
//}
89
//ret /= descriptor_size_;
90
//return ret;
91
//}
92
93
//inline float Narf::getDescriptorDistance(const Narf& other) const
94
//{
95
//float max_diff_between_cells = 0.25;
96
97
//const float* descriptor1_ptr = descriptor_;
98
//const float* descriptor2_ptr = other.getDescriptor();
99
//float ret = 0;
100
//for (int i=0; i<descriptor_size_; ++i) {
101
//ret += (std::min)(max_diff_between_cells, fabsf(*(descriptor2_ptr++) - *(descriptor1_ptr++)));
102
//}
103
//ret /= descriptor_size_*max_diff_between_cells;
104
//return ret;
105
//}
106
107
}
// namespace end