correspondence_rejection_organized_boundary.cpp
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) 2009-2012, Willow Garage, Inc.
00006  *  Copyright (c) 2012-, Open Perception, Inc.
00007  *  Copyright (c) Alexandru-Eugen Ichim
00008  *
00009  *  All rights reserved.
00010  *
00011  *  Redistribution and use in source and binary forms, with or without
00012  *  modification, are permitted provided that the following conditions
00013  *  are met:
00014  *
00015  *  * Redistributions of source code must retain the above copyright
00016  *    notice, this list of conditions and the following disclaimer.
00017  *  * Redistributions in binary form must reproduce the above
00018  *    copyright notice, this list of conditions and the following
00019  *    disclaimer in the documentation and/or other materials provided
00020  *    with the distribution.
00021  *  * Neither the name of the copyright holder(s) nor the names of its
00022  *    contributors may be used to endorse or promote products derived
00023  *    from this software without specific prior written permission.
00024  *
00025  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00026  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00027  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00028  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00029  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00030  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00031  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00032  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00033  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00034  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00035  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00036  *  POSSIBILITY OF SUCH DAMAGE.
00037  */
00038 
00039 #include <pcl/registration/correspondence_rejection_organized_boundary.h>
00040 
00042 void
00043 pcl::registration::CorrespondenceRejectionOrganizedBoundary::getRemainingCorrespondences (const pcl::Correspondences& original_correspondences,
00044                                                                                           pcl::Correspondences& remaining_correspondences)
00045 {
00046   pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud = boost::static_pointer_cast<pcl::registration::DataContainer<pcl::PointXYZ, pcl::PointNormal> >(data_container_)->getInputTarget ();
00047 
00048   if (!cloud->isOrganized ())
00049   {
00050     PCL_ERROR ("[pcl::registration::CorrespondenceRejectionOrganizedBoundary::getRemainingCorrespondences] The target cloud is not organized.\n");
00051     remaining_correspondences.clear ();
00052     return;
00053   }
00054 
00055   remaining_correspondences.reserve (original_correspondences.size ());
00056   for (size_t c_i = 0; c_i < original_correspondences.size (); ++c_i)
00057   {
00059     int x = original_correspondences[c_i].index_match % cloud->width;
00060     int y = original_correspondences[c_i].index_match / cloud->width;
00061 
00062     int nan_count_tgt = 0;
00063     for (int x_d = -window_size_/2; x_d <= window_size_/2; ++x_d)
00064       for (int y_d = -window_size_/2; y_d <= window_size_/2; ++y_d)
00065         if (x + x_d >= 0 && x + x_d < cloud->width &&
00066             y + y_d >= 0 && y + y_d < cloud->height)
00067         {
00068           if (!pcl_isfinite ((*cloud)(x + x_d, y + y_d).z) ||
00069               fabs ((*cloud)(x, y).z - (*cloud)(x + x_d, y + y_d).z) > depth_step_threshold_)
00070             nan_count_tgt ++;
00071         }
00072 
00073     if (nan_count_tgt >= boundary_nans_threshold_)
00074       continue;
00075 
00076 
00078     remaining_correspondences.push_back (original_correspondences[c_i]);
00079   }
00080 }


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:23:05