00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef PCL_RANGE_IMAGE_BORDER_EXTRACTOR_H_
00039 #define PCL_RANGE_IMAGE_BORDER_EXTRACTOR_H_
00040
00041 #include <pcl/point_types.h>
00042 #include <pcl/features/feature.h>
00043
00044 #if defined BUILD_Maintainer && defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ > 3
00045 #pragma GCC diagnostic ignored "-Weffc++"
00046 #endif
00047 namespace pcl
00048 {
00049
00050 class RangeImage;
00051 template <typename PointType>
00052 class PointCloud;
00053
00059 class PCL_EXPORTS RangeImageBorderExtractor : public Feature<PointWithRange,BorderDescription>
00060 {
00061 public:
00062 typedef boost::shared_ptr<RangeImageBorderExtractor> Ptr;
00063 typedef boost::shared_ptr<const RangeImageBorderExtractor> ConstPtr;
00064
00065 typedef Feature<PointWithRange,BorderDescription> BaseClass;
00066
00067
00069 struct LocalSurface
00070 {
00071 LocalSurface () :
00072 normal (), neighborhood_mean (), eigen_values (), normal_no_jumps (),
00073 neighborhood_mean_no_jumps (), eigen_values_no_jumps (), max_neighbor_distance_squared () {}
00074
00075 Eigen::Vector3f normal;
00076 Eigen::Vector3f neighborhood_mean;
00077 Eigen::Vector3f eigen_values;
00078 Eigen::Vector3f normal_no_jumps;
00079 Eigen::Vector3f neighborhood_mean_no_jumps;
00080 Eigen::Vector3f eigen_values_no_jumps;
00081 float max_neighbor_distance_squared;
00082 };
00083
00085 struct ShadowBorderIndices
00086 {
00087 ShadowBorderIndices () : left (-1), right (-1), top (-1), bottom (-1) {}
00088 int left, right, top, bottom;
00089 };
00090
00092 struct Parameters
00093 {
00094 Parameters () : max_no_of_threads(1), pixel_radius_borders (3), pixel_radius_plane_extraction (2), pixel_radius_border_direction (2),
00095 minimum_border_probability (0.8f), pixel_radius_principal_curvature (2) {}
00096 int max_no_of_threads;
00097 int pixel_radius_borders;
00098 int pixel_radius_plane_extraction;
00099 int pixel_radius_border_direction;
00100 float minimum_border_probability;
00101 int pixel_radius_principal_curvature;
00102 };
00103
00104
00108 static inline float
00109 getObstacleBorderAngle (const BorderTraits& border_traits);
00110
00111
00113 RangeImageBorderExtractor (const RangeImage* range_image=NULL);
00115 virtual ~RangeImageBorderExtractor ();
00116
00117
00121 void
00122 setRangeImage (const RangeImage* range_image);
00123
00125 void
00126 clearData ();
00127
00131 float*
00132 getAnglesImageForBorderDirections ();
00133
00137 float*
00138 getAnglesImageForSurfaceChangeDirections ();
00139
00141 void
00142 compute (PointCloudOut& output);
00143
00144
00145 Parameters&
00146 getParameters () { return (parameters_); }
00147
00148 bool
00149 hasRangeImage () const { return range_image_ != NULL; }
00150
00151 const RangeImage&
00152 getRangeImage () const { return *range_image_; }
00153
00154 float*
00155 getBorderScoresLeft () { extractBorderScoreImages (); return border_scores_left_; }
00156
00157 float*
00158 getBorderScoresRight () { extractBorderScoreImages (); return border_scores_right_; }
00159
00160 float*
00161 getBorderScoresTop () { extractBorderScoreImages (); return border_scores_top_; }
00162
00163 float*
00164 getBorderScoresBottom () { extractBorderScoreImages (); return border_scores_bottom_; }
00165
00166 LocalSurface**
00167 getSurfaceStructure () { extractLocalSurfaceStructure (); return surface_structure_; }
00168
00169 PointCloudOut&
00170 getBorderDescriptions () { classifyBorders (); return *border_descriptions_; }
00171
00172 ShadowBorderIndices**
00173 getShadowBorderInformations () { findAndEvaluateShadowBorders (); return shadow_border_informations_; }
00174
00175 Eigen::Vector3f**
00176 getBorderDirections () { calculateBorderDirections (); return border_directions_; }
00177
00178 float*
00179 getSurfaceChangeScores () { calculateSurfaceChanges (); return surface_change_scores_; }
00180
00181 Eigen::Vector3f*
00182 getSurfaceChangeDirections () { calculateSurfaceChanges (); return surface_change_directions_; }
00183
00184
00185 protected:
00186
00187 Parameters parameters_;
00188 const RangeImage* range_image_;
00189 int range_image_size_during_extraction_;
00190 float* border_scores_left_, * border_scores_right_, * border_scores_top_, * border_scores_bottom_;
00191 LocalSurface** surface_structure_;
00192 PointCloudOut* border_descriptions_;
00193 ShadowBorderIndices** shadow_border_informations_;
00194 Eigen::Vector3f** border_directions_;
00195
00196 float* surface_change_scores_;
00197 Eigen::Vector3f* surface_change_directions_;
00198
00199
00200
00210 inline float
00211 getNeighborDistanceChangeScore (const LocalSurface& local_surface, int x, int y,
00212 int offset_x, int offset_y, int pixel_radius=1) const;
00213
00222 inline float
00223 getNormalBasedBorderScore (const LocalSurface& local_surface, int x, int y,
00224 int offset_x, int offset_y) const;
00225
00236 inline bool
00237 changeScoreAccordingToShadowBorderValue (int x, int y, int offset_x, int offset_y, float* border_scores,
00238 float* border_scores_other_direction, int& shadow_border_idx) const;
00239
00246 inline float
00247 updatedScoreAccordingToNeighborValues (int x, int y, const float* border_scores) const;
00248
00253 float*
00254 updatedScoresAccordingToNeighborValues (const float* border_scores) const;
00255
00257 void
00258 updateScoresAccordingToNeighborValues ();
00259
00270 inline bool
00271 checkPotentialBorder (int x, int y, int offset_x, int offset_y, float* border_scores_left,
00272 float* border_scores_right, int& shadow_border_idx) const;
00273
00283 inline bool
00284 checkIfMaximum (int x, int y, int offset_x, int offset_y, float* border_scores, int shadow_border_idx) const;
00285
00287 void
00288 findAndEvaluateShadowBorders ();
00289
00291 void
00292 extractLocalSurfaceStructure ();
00293
00297 void
00298 extractBorderScoreImages ();
00299
00303 void
00304 classifyBorders ();
00305
00311 inline void
00312 calculateBorderDirection (int x, int y);
00313
00317 void
00318 calculateBorderDirections ();
00319
00327 inline bool
00328 get3dDirection (const BorderDescription& border_description, Eigen::Vector3f& direction,
00329 const LocalSurface* local_surface=NULL);
00330
00339 inline bool
00340 calculateMainPrincipalCurvature (int x, int y, int radius, float& magnitude,
00341 Eigen::Vector3f& main_direction) const;
00342
00345 void
00346 calculateSurfaceChanges ();
00347
00349 void
00350 blurSurfaceChanges ();
00351
00353 virtual void
00354 computeFeature (PointCloudOut &output);
00355 };
00356 }
00357 #if defined BUILD_Maintainer && defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ > 3
00358 #pragma GCC diagnostic warning "-Weffc++"
00359 #endif
00360
00361 #include <pcl/features/impl/range_image_border_extractor.hpp>
00362
00363 #endif //#ifndef PCL_RANGE_IMAGE_BORDER_EXTRACTOR_H_