narf.hpp
Go to the documentation of this file.
00001 
00059 /*
00060  * narf.hpp
00061  *
00062  *  Created on: Nov 15, 2011
00063  *      Author: goa-jh
00064  */
00065 
00066 #ifndef NARF_HPP_
00067 #define NARF_HPP_
00068 
00069 
00070 template<typename Point>
00071 void Feature_NARF<Point>::extractFeatures(const pcl::PointCloud<Point>& point_cloud, pcl::PointCloud<pcl::Narf36> &narf_descriptors) {
00072   float angular_resolution = 0.0005f;
00073   float support_size = 0.3f;
00074   pcl::RangeImage::CoordinateFrame coordinate_frame = pcl::RangeImage::CAMERA_FRAME;
00075   bool setUnseenToMaxRange = false;
00076   bool rotation_invariant = true;
00077 
00078 
00079 
00080   // ------------------------------
00081   // -----Setting viewpoint up-----
00082   // ------------------------------
00083   pcl::PointCloud<pcl::PointWithViewpoint> far_ranges;
00084   Eigen::Affine3f scene_sensor_pose (Eigen::Affine3f::Identity ());
00085 
00086   scene_sensor_pose = Eigen::Affine3f (Eigen::Translation3f (point_cloud.sensor_origin_[0],
00087                                                              point_cloud.sensor_origin_[1],
00088                                                              point_cloud.sensor_origin_[2])) *
00089                       Eigen::Affine3f (point_cloud.sensor_orientation_);
00090 
00091   scene_sensor_pose = scene_sensor_pose.Identity();
00092 
00093   // -----------------------------------------------
00094   // -----Create RangeImage from the PointCloud-----
00095   // -----------------------------------------------
00096   float noise_level = 0.0;
00097   float min_range = 0.0f;
00098   int border_size = 1;
00099   boost::shared_ptr<pcl::RangeImage> range_image_ptr (new pcl::RangeImage);
00100   pcl::RangeImage& range_image = *range_image_ptr;
00101   range_image.createFromPointCloud (point_cloud, angular_resolution, pcl::deg2rad (360.0f), pcl::deg2rad (180.0f),
00102                                    scene_sensor_pose, coordinate_frame, noise_level, min_range, border_size);
00103   range_image.integrateFarRanges (far_ranges);
00104   if (setUnseenToMaxRange)
00105     range_image.setUnseenToMaxRange ();
00106 
00107   ROS_INFO("range image %d %d", range_image.height, range_image.width);
00108 
00109   // --------------------------------
00110   // -----Extract NARF keypoints-----
00111   // --------------------------------
00112   pcl::RangeImageBorderExtractor range_image_border_extractor;
00113   pcl::NarfKeypoint narf_keypoint_detector;
00114   narf_keypoint_detector.setRangeImageBorderExtractor (&range_image_border_extractor);
00115   narf_keypoint_detector.setRangeImage (&range_image);
00116   narf_keypoint_detector.getParameters ().support_size = support_size;
00117   narf_keypoint_detector.getParameters ().min_interest_value/=2;
00118   narf_keypoint_detector.getParameters ().do_non_maximum_suppression=true;
00119 
00120   pcl::PointCloud<int> keypoint_indices;
00121   narf_keypoint_detector.compute (keypoint_indices);
00122   std::cout << "Found "<<keypoint_indices.points.size ()<<" key points.\n";
00123 
00124   // ------------------------------------------------------
00125   // -----Extract NARF descriptors for interest points-----
00126   // ------------------------------------------------------
00127   std::vector<int> keypoint_indices2;
00128   keypoint_indices2.resize (keypoint_indices.points.size ());
00129   for (unsigned int i=0; i<keypoint_indices.size (); ++i) { // This step is necessary to get the right vector type
00130     keypoint_indices2[i]=keypoint_indices.points[i];
00131   }
00132   pcl::NarfDescriptor narf_descriptor (&range_image, &keypoint_indices2);
00133   narf_descriptor.getParameters ().support_size = support_size;
00134   narf_descriptor.getParameters ().rotation_invariant = rotation_invariant;
00135   narf_descriptor.compute (narf_descriptors);
00136 
00137 }
00138 
00139 #endif /* NARF_HPP_ */


cob_3d_registration
Author(s): Joshua Hampp
autogenerated on Wed Aug 26 2015 11:02:36