|
Point Cloud Library (PCL)
1.6.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2012, 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 * $Id$ 00035 */ 00036 00037 #ifndef PCL_FEATURES_IMPL_SHOT_LRF_OMP_H_ 00038 #define PCL_FEATURES_IMPL_SHOT_LRF_OMP_H_ 00039 00040 #include <utility> 00041 #include <pcl/features/shot_lrf_omp.h> 00042 #include <pcl/features/shot_lrf.h> 00043 00044 template<typename PointInT, typename PointOutT> 00045 void 00046 pcl::SHOTLocalReferenceFrameEstimationOMP<PointInT, PointOutT>::computeFeature (PointCloudOut &output) 00047 { 00048 if (threads_ < 0) 00049 threads_ = 1; 00050 00051 //check whether used with search radius or search k-neighbors 00052 if (this->getKSearch () != 0) 00053 { 00054 PCL_ERROR( 00055 "[pcl::%s::computeFeature] Error! Search method set to k-neighborhood. Call setKSearch(0) and setRadiusSearch( radius ) to use this class.\n", 00056 getClassName().c_str ()); 00057 return; 00058 } 00059 tree_->setSortedResults (true); 00060 00061 int data_size = static_cast<int> (indices_->size ()); 00062 #pragma omp parallel for num_threads(threads_) 00063 for (int i = 0; i < data_size; ++i) 00064 { 00065 // point result 00066 Eigen::Matrix3f rf; 00067 PointOutT& output_rf = output[i]; 00068 00069 //output_rf.confidence = getLocalRF ((*indices_)[i], rf); 00070 //if (output_rf.confidence == std::numeric_limits<float>::max ()) 00071 00072 std::vector<int> n_indices; 00073 std::vector<float> n_sqr_distances; 00074 this->searchForNeighbors ((*indices_)[i], search_parameter_, n_indices, n_sqr_distances); 00075 if (getLocalRF ((*indices_)[i], rf) == std::numeric_limits<float>::max ()) 00076 { 00077 output.is_dense = false; 00078 } 00079 00080 output_rf.x_axis.getNormalVector3fMap () = rf.row (0); 00081 output_rf.y_axis.getNormalVector3fMap () = rf.row (1); 00082 output_rf.z_axis.getNormalVector3fMap () = rf.row (2); 00083 } 00084 00085 } 00086 00087 template<typename PointInT, typename PointOutT> 00088 void 00089 pcl::SHOTLocalReferenceFrameEstimationOMP<PointInT, PointOutT>::computeFeatureEigen (pcl::PointCloud<Eigen::MatrixXf> &output) 00090 { 00091 if (threads_ < 0) 00092 threads_ = 1; 00093 00094 //check whether used with search radius or search k-neighbors 00095 if (this->getKSearch () != 0) 00096 { 00097 PCL_ERROR( 00098 "[pcl::%s::computeFeatureEigen] Error! Search method set to k-neighborhood. Call setKSearch(0) and setRadiusSearch( radius ) to use this class.\n", 00099 getClassName().c_str ()); 00100 return; 00101 } 00102 tree_->setSortedResults (true); 00103 00104 int data_size = static_cast<int> (indices_->size ()); 00105 00106 // Set up the output channels 00107 output.channels["shot_lrf"].name = "shot_lrf"; 00108 output.channels["shot_lrf"].offset = 0; 00109 output.channels["shot_lrf"].size = 4; 00110 output.channels["shot_lrf"].count = 9; 00111 output.channels["shot_lrf"].datatype = sensor_msgs::PointField::FLOAT32; 00112 00113 //output.points.resize (indices_->size (), 10); 00114 output.points.resize (data_size, 9); 00115 00116 #pragma omp parallel for num_threads(threads_) 00117 for (int i = 0; i < data_size; ++i) 00118 { 00119 // point result 00120 Eigen::Matrix3f rf; 00121 00122 //output.points (i, 9) = getLocalRF ((*indices_)[i], rf); 00123 //if (output.points (i, 9) == std::numeric_limits<float>::max ()) 00124 if (getLocalRF ((*indices_)[i], rf) == std::numeric_limits<float>::max ()) 00125 { 00126 output.is_dense = false; 00127 } 00128 00129 output.points.block<1, 3> (i, 0) = rf.row (0); 00130 output.points.block<1, 3> (i, 3) = rf.row (1); 00131 output.points.block<1, 3> (i, 6) = rf.row (2); 00132 } 00133 00134 } 00135 00136 #define PCL_INSTANTIATE_SHOTLocalReferenceFrameEstimationOMP(T,OutT) template class PCL_EXPORTS pcl::SHOTLocalReferenceFrameEstimationOMP<T,OutT>; 00137 00138 #endif // PCL_FEATURES_IMPL_SHOT_LRF_H_
1.7.6.1