Loading...
Searching...
No Matches
narf.hpp
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010, Willow Garage, Inc.
* Copyright (c) 2012-, Open Perception, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <iostream>
#include <pcl/common/norms.h> // for L1_Norm
#include <pcl/common/eigen.h>
namespace pcl {
inline float
Narf::getDescriptorDistance(const Narf& other) const
{
float ret = L1_Norm(descriptor_, other.descriptor_, descriptor_size_);
//float ret = Sublinear_Norm(descriptor_, other.descriptor_, descriptor_size_);
ret /= static_cast<float> (descriptor_size_);
return (ret);
}
inline void Narf::copyToNarf36(Narf36& narf36) const
{
if (descriptor_size_ != 36)
{
std::cerr << __PRETTY_FUNCTION__ << ": descriptor size is not 36!\n";
return;
}
getTranslationAndEulerAngles(transformation_.inverse (), narf36.x, narf36.y, narf36.z, narf36.roll, narf36.pitch, narf36.yaw);
std::copy(descriptor_, descriptor_ + 36, narf36.descriptor);
}
//inline float Narf::getDescriptorDistance(const Narf& other) const
//{
//float middle_value = 0.1f;
//float normalization_factor1 = 1.0f/middle_value,
//normalization_factor2 = 1.0f/(1.0f-middle_value);
//const float* descriptor1_ptr = descriptor_;
//const float* descriptor2_ptr = other.getDescriptor();
//float ret = 0;
//for (int i=0; i<descriptor_size_; ++i) {
//float diff = std::abs(*(descriptor2_ptr++) - *(descriptor1_ptr++));
//if (diff < middle_value)
//{
//diff = diff*normalization_factor1;
//diff = 0.5f*diff*diff;
////diff = 0.5f*powf(diff, 2);
//}
//else
//{
//diff = (diff - middle_value)*normalization_factor2;
//diff = 0.5f + 0.5f*diff;
////diff = 0.5f + 0.5f*std::sqrt(diff);
////diff = 0.5f + 0.5f*powf(diff, 0.3f);
//}
//ret += diff;
//}
//ret /= descriptor_size_;
//return ret;
//}
//inline float Narf::getDescriptorDistance(const Narf& other) const
//{
//float max_diff_between_cells = 0.25;
//const float* descriptor1_ptr = descriptor_;
//const float* descriptor2_ptr = other.getDescriptor();
//float ret = 0;
//for (int i=0; i<descriptor_size_; ++i) {
//ret += (std::min)(max_diff_between_cells, std::abs(*(descriptor2_ptr++) - *(descriptor1_ptr++)));
//}
//ret /= descriptor_size_*max_diff_between_cells;
//return ret;
//}
} // namespace end
pcl::Narf
NARF (Normal Aligned Radial Features) is a point feature descriptor type for 3D data.
Definition narf.h:66
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::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:593
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:1566
pcl::Narf36::roll
float roll
Definition point_types.hpp:1567
pcl::Narf36::pitch
float pitch
Definition point_types.hpp:1567
pcl::Narf36::z
float z
Definition point_types.hpp:1567
pcl::Narf36::y
float y
Definition point_types.hpp:1567
pcl::Narf36::yaw
float yaw
Definition point_types.hpp:1567
pcl::Narf36::descriptor
float descriptor[36]
Definition point_types.hpp:1568
pcl::Narf36::x
float x
Definition point_types.hpp:1567