point_types.h

Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2010, 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: point_types.h 3006 2011-10-31 23:25:06Z rusu $
00035  *
00036  */
00037 #ifndef PCL_DATA_TYPES_H_
00038 #define PCL_DATA_TYPES_H_
00039 
00040 #include "pcl/pcl_macros.h"
00041 #include <Eigen/Core>
00042 #include <bitset>
00043 #include <vector>
00044 #include "pcl/ros/register_point_struct.h"
00045 #include "pcl/win32_macros.h"
00046 #include <math.h>
00047 
00055 namespace pcl
00056 {
00057   struct PointXYZ;
00058   // Members: float x, y, z;
00059 
00060   struct PointXYZI;
00061   // Members: float x, y, z, intensity; 
00062 
00063   struct PointXYZL;
00064   // Members: float x, y, z, uin8_t label;
00065 
00066   struct PointXYZRGBA;
00067   // Members: float x, y, z; uint32_t rgba;
00068 
00069   struct PointXYZRGB;
00070   // Members: float x, y, z, rgb;
00071 
00072   struct PointXYZRGBL;
00073   // Members: float x, y, z, rgb, uint8_t label;
00074 
00075   struct PointXYZHSV;
00076   // Members: float x, y, z, h, s, v;
00077 
00078   struct PointXY;
00079   // Members: float x, y;
00080 
00081   struct InterestPoint;
00082   // Members: float x, y, z, strength;
00083 
00084   struct Normal;
00085   // Members: float normal[3], curvature;
00086 
00087   struct PointNormal;
00088   // Members: float x, y, z; float normal[3], curvature;
00089 
00090   struct PointXYZRGBNormal;
00091   // Members: float x, y, z, rgb, normal[3], curvature;
00092 
00093   struct PointXYZINormal;
00094   // Members: float x, y, z, intensity, normal[3], curvature;
00095 
00096   struct PointWithRange;
00097   // Members: float x, y, z (union with float point[4]), range;
00098 
00099   struct PointWithViewpoint;
00100   // Members: float x, y, z, vp_x, vp_y, vp_z;
00101 
00102   struct MomentInvariants;
00103   // Members: float j1, j2, j3;
00104 
00105   // TODO add point type for Radius-based Surface Descriptor (RSD) histograms, and let pcl::RSDEstimation return it if needed
00106 
00107   struct PrincipalRadiiRSD;
00108   // Members: float r_min, r_max;
00109 
00110   struct Boundary;
00111   // Members: uint8_t boundary_point;
00112 
00113   struct PrincipalCurvatures;
00114   // Members: float principal_curvature[3], pc1, pc2;
00115 
00116   //struct SHOT352;
00117   // Members: float descriptor[352], rf[9];
00118 
00119   struct SHOT;
00120   // Members: std::vector<float> descriptor, rf[9];
00121 
00122   //struct SHOT1344;
00123   // Members: float descriptor[1344], rf[9];
00124 
00125   struct PFHSignature125;
00126   // Members: float pfh[125];
00127 
00128   struct PFHRGBSignature250;
00129   // Members: float pfhrgb[250];
00130 
00131   struct PPFSignature;
00132   // Members: float f1, f2, f3, f4, alpha_m;
00133 
00134   struct PPFRGBSignature;
00135   // Members: float f1, f2, f3, f4, r_ratio, g_ratio, b_ratio, alpha_m
00136 
00137   struct NormalBasedSignature12;
00138   // Members: float values[12];
00139 
00140   struct FPFHSignature33;
00141   // Members: float fpfh[33];
00142 
00143   struct VFHSignature308;
00144   // Members: float vfh[308];
00145 
00146   struct Narf36;
00147   // Members: float x, y, z, roll, pitch, yaw; float descriptor[36];
00148 
00149 
00153   typedef std::bitset<32> BorderTraits;
00154 
00158   enum BorderTrait
00159   {
00160     BORDER_TRAIT__OBSTACLE_BORDER, BORDER_TRAIT__SHADOW_BORDER, BORDER_TRAIT__VEIL_POINT,
00161     BORDER_TRAIT__SHADOW_BORDER_TOP, BORDER_TRAIT__SHADOW_BORDER_RIGHT, BORDER_TRAIT__SHADOW_BORDER_BOTTOM,
00162     BORDER_TRAIT__SHADOW_BORDER_LEFT, BORDER_TRAIT__OBSTACLE_BORDER_TOP, BORDER_TRAIT__OBSTACLE_BORDER_RIGHT,
00163     BORDER_TRAIT__OBSTACLE_BORDER_BOTTOM, BORDER_TRAIT__OBSTACLE_BORDER_LEFT, BORDER_TRAIT__VEIL_POINT_TOP,
00164     BORDER_TRAIT__VEIL_POINT_RIGHT, BORDER_TRAIT__VEIL_POINT_BOTTOM, BORDER_TRAIT__VEIL_POINT_LEFT,
00165   };
00166 
00167   struct BorderDescription;
00168   // Members: int x, y; BorderTraits traits;
00169 
00170   struct IntensityGradient;
00171   // Members: float gradient[3];
00172 
00173   template<int N>
00174     struct Histogram;
00175   // Members: float histogram[N];
00176 
00177   struct PointWithScale;
00178   // Members: float x, y, z, scale;
00179 
00180   struct PointSurfel;
00181   // Members: float x, y, z, normal[3], rgba, radius, confidence, curvature;
00182 
00183   // -----Functions on points-----
00185   template<typename PointType1, typename PointType2>
00186     inline float
00187     euclideanDistance (const PointType1& p1, const PointType2& p2);
00188 
00190   template<typename PointType1, typename PointType2>
00191     inline float
00192     squaredEuclideanDistance (const PointType1& p1, const PointType2& p2);
00193 
00195   template<typename PointType>
00196     inline bool
00197     hasValidXYZ (const PointType& p);
00198 }
00199 
00202 #include "pcl/impl/point_types.hpp"  // Include struct definitions
00203 
00204 // ==============================
00205 // =====POINT_CLOUD_REGISTER=====
00206 // ==============================
00207 
00208 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZ,
00209     (float, x, x)
00210     (float, y, y)
00211     (float, z, z)
00212 )
00213 POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZ, pcl::_PointXYZ)
00214 
00215 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZRGBA,
00216     (float, x, x)
00217     (float, y, y)
00218     (float, z, z)
00219     (uint32_t, rgba, rgba)
00220 )
00221 POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZRGBA, pcl::_PointXYZRGBA)
00222 
00223 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZRGB,
00224     (float, x, x)
00225     (float, y, y)
00226     (float, z, z)
00227     (float, rgb, rgb)
00228 )
00229 POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZRGB, pcl::_PointXYZRGB)
00230 
00231 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZRGBL,
00232     (float, x, x)
00233     (float, y, y)
00234     (float, z, z)
00235     (uint32_t, rgba, rgba)
00236     (uint8_t, label, label)
00237 )
00238 POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZRGBL, pcl::_PointXYZRGBL)
00239 
00240 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZHSV,
00241     (float, x, x)
00242     (float, y, y)
00243     (float, z, z)
00244     (float, h, h)
00245     (float, s, s)
00246     (float, v, v)
00247 )
00248 POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZHSV, pcl::_PointXYZHSV)
00249 
00250 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointXY,
00251     (float, x, x)
00252     (float, y, y)
00253 )
00254 
00255 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::InterestPoint,
00256     (float, x, x)
00257     (float, y, y)
00258     (float, z, z)
00259     (float, strength, strength)
00260 )
00261 
00262 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointXYZI,
00263     (float, x, x)
00264     (float, y, y)
00265     (float, z, z)
00266     (float, intensity, intensity)
00267 )
00268 
00269 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointXYZL,
00270     (float, x, x)
00271     (float, y, y)
00272     (float, z, z)
00273     (uint8_t, label, label)
00274 )
00275 
00276 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::Normal,
00277     (float, normal_x, normal_x)
00278     (float, normal_y, normal_y)
00279     (float, normal_z, normal_z)
00280     (float, curvature, curvature)
00281 )
00282 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointNormal,
00283     (float, x, x)
00284     (float, y, y)
00285     (float, z, z)
00286     (float, normal_x, normal_x)
00287     (float, normal_y, normal_y)
00288     (float, normal_z, normal_z)
00289     (float, curvature, curvature)
00290 )
00291 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZRGBNormal,
00292     (float, x, x)
00293     (float, y, y)
00294     (float, z, z)
00295     (float, rgb, rgb)
00296     (float, normal_x, normal_x)
00297     (float, normal_y, normal_y)
00298     (float, normal_z, normal_z)
00299     (float, curvature, curvature)
00300 )
00301 POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZRGBNormal, pcl::_PointXYZRGBNormal)
00302 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointXYZINormal,
00303     (float, x, x)
00304     (float, y, y)
00305     (float, z, z)
00306     (float, intensity, intensity)
00307     (float, normal_x, normal_x)
00308     (float, normal_y, normal_y)
00309     (float, normal_z, normal_z)
00310     (float, curvature, curvature)
00311 )
00312 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointWithRange,
00313     (float, x, x)
00314     (float, y, y)
00315     (float, z, z)
00316     (float, range, range)
00317 )
00318 
00319 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointWithViewpoint,
00320     (float, x, x)
00321     (float, y, y)
00322     (float, z, z)
00323     (float, vp_x, vp_x)
00324     (float, vp_y, vp_y)
00325     (float, vp_z, vp_z)
00326 )
00327 POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointWithViewpoint, pcl::_PointWithViewpoint)
00328 
00329 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::MomentInvariants,
00330     (float, j1, j1)
00331     (float, j2, j2)
00332     (float, j3, j3)
00333 )
00334 
00335 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PrincipalRadiiRSD,
00336     (float, r_min, r_min)
00337     (float, r_max, r_max)
00338 )
00339 
00340 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::Boundary,
00341     (uint8_t, boundary_point, boundary_point)
00342 )
00343 
00344 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PrincipalCurvatures,
00345     (float, principal_curvature_x, principal_curvature_x)
00346     (float, principal_curvature_y, principal_curvature_y)
00347     (float, principal_curvature_z, principal_curvature_z)
00348     (float, pc1, pc1)
00349     (float, pc2, pc2)
00350 )
00351 
00352 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PFHSignature125,
00353     (float[125], histogram, pfh)
00354 )
00355 
00356 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PFHRGBSignature250,
00357     (float[250], histogram, pfhrgb)
00358 )
00359 
00360 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PPFSignature,
00361     (float, f1, f1)
00362     (float, f2, f2)
00363     (float, f3, f3)
00364     (float, f4, f4)
00365     (float, alpha_m, alpha_m)
00366 )
00367 
00368 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PPFRGBSignature,
00369     (float, f1, f1)
00370     (float, f2, f2)
00371     (float, f3, f3)
00372     (float, f4, f4)
00373     (float, r_ratio, r_ratio)
00374     (float, g_ratio, g_ratio)
00375     (float, b_ratio, b_ratio)
00376     (float, alpha_m, alpha_m)
00377 )
00378 
00379 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::NormalBasedSignature12,
00380     (float[12], values, values)
00381 )
00382 
00383 //POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_SHOT352,
00384 //                                   (float[352], descriptor, shot)
00385 //                                   (float[9], rf, rf)
00386 //                                   (uint32_t, size, size)
00387 //)
00388 //POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::SHOT352, pcl::_SHOT352)
00389 //
00390 //POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_SHOT1344,
00391 //                                   (float[1344], descriptor, shot)
00392 //                                   (float[9], rf, rf)
00393 //                                   (uint32_t, size, size)
00394 //)
00395 //POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::SHOT1344, pcl::_SHOT1344)
00396 
00397 
00398 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::FPFHSignature33,
00399     (float[33], histogram, fpfh)
00400 )
00401 
00402 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::VFHSignature308,
00403     (float[308], histogram, vfh)
00404 )
00405 
00406 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::Narf36,
00407     (float[36], descriptor, descriptor)
00408 )
00409 
00410 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::IntensityGradient,
00411     (float, gradient_x, gradient_x)
00412     (float, gradient_y, gradient_y)
00413     (float, gradient_z, gradient_z)
00414 )
00415 
00416 POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PointWithScale,
00417     (float, x, x)
00418     (float, y, y)
00419     (float, z, z)
00420     (float, scale, scale)
00421 )
00422 
00423 POINT_CLOUD_REGISTER_POINT_STRUCT(pcl::PointSurfel,
00424     (float, x, x)
00425     (float, y, y)
00426     (float, z, z)
00427     (float, normal_x, normal_x)
00428     (float, normal_y, normal_y)
00429     (float, normal_z, normal_z)
00430     (uint32_t, rgba, rgba)
00431     (float, radius, radius)
00432     (float, confidence, confidence)
00433     (float, curvature, curvature)
00434 )
00435 
00436 //POINT_CLOUD_REGISTER_POINT_STRUCT(pcl::BorderDescription,
00437 //                                  (int, x, x)
00438 //                                  (int, y, y)
00439 //                                  (uint32_t, traits, traits)
00440 //)
00441 
00442 
00443 #endif  //#ifndef PCL_DATA_TYPES_H_