1 #ifndef OBJECT_RECOGNITION_H_
2 #define OBJECT_RECOGNITION_H_
5 #include "load_clouds.h"
7 #include "segmentation.h"
8 #include "feature_estimation.h"
9 #include "registration.h"
11 #include <pcl/io/pcd_io.h>
12 #include <pcl/kdtree/kdtree_flann.h>
66 size_t n = filenames.size ();
69 for (
size_t i = 0; i < n; ++i)
71 const std::string & filename = filenames[i];
72 if (filename.compare (filename.size ()-4, 4,
".pcd") == 0)
83 models_[i].points = loadPointCloud<PointT> (filename,
"_points.pcd");
84 models_[i].keypoints = loadPointCloud<PointT> (filename,
"_keypoints.pcd");
85 models_[i].local_descriptors = loadPointCloud<LocalDescriptorT> (filename,
"_localdesc.pcd");
86 models_[i].global_descriptor = loadPointCloud<GlobalDescriptorT> (filename,
"_globaldesc.pcd");
101 std::vector<int> nn_index (1);
102 std::vector<float> nn_sqr_distance (1);
103 kdtree_->nearestKSearch (query_descriptor, 1, nn_index, nn_sqr_distance);
104 const int & best_match = nn_index[0];
116 std::vector<int> nn_index (1);
117 std::vector<float> nn_sqr_distance (1);
118 kdtree_->nearestKSearch (query_descriptor, 1, nn_index, nn_sqr_distance);
119 const int & best_match = nn_index[0];
131 SurfaceNormalsPtr normals;
147 std::vector<pcl::PointIndices> cluster_indices;
151 PointCloudPtr largest_cluster (
new PointCloud);
154 return (largest_cluster);
160 SurfaceNormalsPtr & normals_out, PointCloudPtr & keypoints_out,
161 LocalDescriptorsPtr & local_descriptors_out, GlobalDescriptorsPtr & global_descriptor_out)
const
168 local_descriptors_out = computeLocalDescriptors (points, normals_out, keypoints_out,
171 global_descriptor_out = computeGlobalDescriptor (points, normals_out);
179 Eigen::Matrix4f tform;
186 tform = refineAlignment (source.
points, target.
points, tform,
float initial_alignment_min_sample_distance
ObjectRecognitionParameters params_
float initial_alignment_max_correspondence_distance
PCL_EXPORTS void copyPointCloud(const pcl::PCLPointCloud2 &cloud_in, const std::vector< int > &indices, pcl::PCLPointCloud2 &cloud_out)
Extract the indices of a given point cloud as a new point cloud.
int max_ransac_iterations
float keypoints_nr_octaves
int outlier_rejection_min_neighbors
float local_descriptor_radius
float keypoints_min_contrast
float downsample_leaf_size
boost::shared_ptr< KdTreeFLANN< PointT > > Ptr
ObjectRecognition(const ObjectRecognitionParameters ¶ms)
PointCloudPtr recognizeAndAlignPoints(const PointCloudPtr &query_cloud)
void transformPointCloud(const pcl::PointCloud< PointT > &cloud_in, pcl::PointCloud< PointT > &cloud_out, const Eigen::Transform< Scalar, 3, Eigen::Affine > &transform)
Apply an affine transform defined by an Eigen Transform.
void estimateFeatures(const PointCloudPtr &points, const ObjectRecognitionParameters ¶ms, SurfaceNormalsPtr &normals_out, PointCloudPtr &keypoints_out, LocalDescriptorsPtr &local_descriptors_out, GlobalDescriptorsPtr &global_descriptor_out) const
KdTreeFLANN is a generic type of 3D spatial locator using kD-tree structures.
float surface_normal_radius
float icp_outlier_rejection_threshold
pcl::KdTreeFLANN< GlobalDescriptorT >::Ptr kdtree_
float icp_max_correspondence_distance
float icp_transformation_epsilon
int loadPCDFile(const std::string &file_name, pcl::PCLPointCloud2 &cloud)
Load a PCD v.6 file into a templated PointCloud type.
float plane_inlier_distance_threshold
float keypoints_min_scale
PointCloudPtr alignModelPoints(const ObjectModel &source, const ObjectModel &target, const ObjectRecognitionParameters ¶ms) const
float outlier_rejection_radius
LocalDescriptorsPtr local_descriptors
float keypoints_nr_scales_per_octave
int initial_alignment_nr_iterations
void populateDatabase(const std::vector< std::string > &filenames)
void constructObjectModel(const PointCloudPtr &points, ObjectModel &output) const
A point structure representing the Viewpoint Feature Histogram (VFH).
std::vector< ObjectModel > models_
PointCloudPtr applyFiltersAndSegment(const PointCloudPtr &input, const ObjectRecognitionParameters ¶ms) const
GlobalDescriptorsPtr global_descriptor
GlobalDescriptorsPtr descriptors_
const ObjectModel & recognizeObject(const PointCloudPtr &query_cloud)