object_model_list.cpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2010, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Willow Garage, Inc. nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  */
00035 
00036 /* \author Bastian Steder */
00037 
00038 
00039 #include <narf_recognition/object_model_list.h>
00040 #include <iostream>
00041 using std::cout;
00042 using std::cerr;
00043 using std::vector;
00044 
00045 namespace pcl
00046 {
00047 
00048 ObjectModelList::ObjectModelList () : BaseClass ()
00049 {
00050 }
00051 
00052 ObjectModelList::~ObjectModelList ()
00053 {
00054   while (!empty ())
00055   {
00056     delete back ();
00057     pop_back ();
00058   }
00059 }
00060 
00061 void ObjectModelList::extractNARFsForCompleteSurface (unsigned int descriptor_size, float size_in_world, bool rotation_invariant,
00062                                                     vector<vector<vector<Narf*>*>*>& features) const
00063 {
00064   //MEASURE_FUNCTION_TIME;
00065   freeFeatureListMemory (features);
00066   for (const_iterator it=begin (); it!=end (); ++it)
00067   {
00068     features.push_back (new vector<vector<Narf*>*>);
00069     
00070     const ObjectModel& object_model = **it;
00071     vector<vector<Narf*>*>& features_for_current_model = *features.back ();
00072     
00073     object_model.extractNARFsForCompleteSurface (descriptor_size, size_in_world, rotation_invariant, features_for_current_model);
00074   }
00075 }
00076 
00077 void
00078 ObjectModelList::extractNARFsForInterestPoints (unsigned int descriptor_size, float size_in_world,
00079                                                bool rotation_invariant, NarfKeypoint& interest_point_detector,
00080                                                vector<vector<vector<Narf*>*>*>& features) const
00081 {
00082   //MEASURE_FUNCTION_TIME;
00083   freeFeatureListMemory (features);
00084   for (const_iterator it=begin (); it!=end (); ++it)
00085   {
00086     features.push_back (new vector<vector<Narf*>*>);
00087     
00088     const ObjectModel& object_model = **it;
00089     vector<vector<Narf*>*>& features_for_current_model = *features.back ();
00090     
00091     object_model.extractNARFsForInterestPoints (descriptor_size, size_in_world, rotation_invariant, interest_point_detector, features_for_current_model);
00092     
00093     //for (unsigned int view_idx=0; view_idx<features_for_current_model.size (); ++view_idx)
00094       //std::cout << "Extracted "<<features_for_current_model[view_idx]->size ()<<" features for model "
00095       //          << object_model.getName ()<<", view "<<view_idx<<".\n";
00096   }
00097 }
00098 
00099 float
00100 ObjectModelList::getAverageModelRadius () const
00101 {
00102   if (empty ())
00103     return 0.0f;
00104   float average_model_radius = 0.0f;
00105   for (size_t model_idx=0; model_idx<size (); ++model_idx)
00106     average_model_radius += at (model_idx)->getRadius ();
00107   average_model_radius /= float (size ()); 
00108   return average_model_radius;
00109 }
00110 
00111 float
00112 ObjectModelList::getMaximumPlaneSize (float initial_max_plane_error) const
00113 {
00114   float maximum_plane_size = 0.0f;
00115   for (size_t model_idx=0; model_idx<size (); ++model_idx)
00116     maximum_plane_size = std::max (maximum_plane_size, at (model_idx)->getMaximumPlaneSize (initial_max_plane_error));
00117   return maximum_plane_size;
00118 }
00119 
00120 } // namespace end
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


chair_recognition
Author(s): Jan Metzger
autogenerated on Wed Dec 26 2012 15:54:47