narf.hpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2010, Willow Garage, Inc.
00006  *  Copyright (c) 2012-, Open Perception, Inc.
00007  *
00008  *  All rights reserved.
00009  *
00010  *  Redistribution and use in source and binary forms, with or without
00011  *  modification, are permitted provided that the following conditions
00012  *  are met:
00013  *
00014  *   * Redistributions of source code must retain the above copyright
00015  *     notice, this list of conditions and the following disclaimer.
00016  *   * Redistributions in binary form must reproduce the above
00017  *     copyright notice, this list of conditions and the following
00018  *     disclaimer in the documentation and/or other materials provided
00019  *     with the distribution.
00020  *   * Neither the name of the copyright holder(s) nor the names of its
00021  *     contributors may be used to endorse or promote products derived
00022  *     from this software without specific prior written permission.
00023  *
00024  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00026  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00027  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00028  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00029  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00030  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00031  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00034  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00035  *  POSSIBILITY OF SUCH DAMAGE.
00036  *
00037  */
00038 
00039 #include <iostream>
00040 #include <map>
00041 
00042 namespace pcl {
00043 
00044 inline float 
00045 Narf::getDescriptorDistance(const Narf& other) const
00046 {
00047   float ret = L1_Norm(descriptor_, other.descriptor_, descriptor_size_);
00048   //float ret = Sublinear_Norm(descriptor_, other.descriptor_, descriptor_size_);
00049   ret /= static_cast<float> (descriptor_size_);
00050   return (ret);
00051 }
00052 
00053 inline void Narf::copyToNarf36(Narf36& narf36) const
00054 {
00055   if (descriptor_size_ != 36)
00056   {
00057     std::cerr << __PRETTY_FUNCTION__ << ": descriptor size is not 36!\n";
00058     return;
00059   }
00060   getTranslationAndEulerAngles(transformation_.inverse (), narf36.x, narf36.y, narf36.z, narf36.roll, narf36.pitch, narf36.yaw);
00061   memcpy(narf36.descriptor, descriptor_, 36*sizeof(*descriptor_));
00062 }
00063 
00064 //inline float Narf::getDescriptorDistance(const Narf& other) const
00065 //{
00066   //float middle_value = 0.1f;
00067   //float normalization_factor1 = 1.0f/middle_value,
00068         //normalization_factor2 = 1.0f/(1.0f-middle_value);
00069   //const float* descriptor1_ptr = descriptor_;
00070   //const float* descriptor2_ptr = other.getDescriptor();
00071   //float ret = 0;
00072   //for (int i=0; i<descriptor_size_; ++i) {
00073     //float diff = fabsf(*(descriptor2_ptr++) - *(descriptor1_ptr++));
00074     //if (diff < middle_value)
00075     //{
00076       //diff = diff*normalization_factor1;
00077       //diff = 0.5f*diff*diff;
00079     //}
00080     //else
00081     //{
00082       //diff = (diff - middle_value)*normalization_factor2;
00083       //diff = 0.5f + 0.5f*diff;
00086     //}
00087     //ret += diff;
00088   //}
00089   //ret /= descriptor_size_;
00090   //return ret;
00091 //}
00092 
00093 //inline float Narf::getDescriptorDistance(const Narf& other) const
00094 //{
00095   //float max_diff_between_cells = 0.25;
00096   
00097   //const float* descriptor1_ptr = descriptor_;
00098   //const float* descriptor2_ptr = other.getDescriptor();
00099   //float ret = 0;
00100   //for (int i=0; i<descriptor_size_; ++i) {
00101     //ret += (std::min)(max_diff_between_cells, fabsf(*(descriptor2_ptr++) - *(descriptor1_ptr++)));
00102   //}
00103   //ret /= descriptor_size_*max_diff_between_cells;
00104   //return ret;
00105 //}
00106 
00107 }  // namespace end


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:25:42