Go to the documentation of this file.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
00039
00040
00041 #ifndef PCL_FILTERS_VOXEL_GRID_OCCLUSION_ESTIMATION_H_
00042 #define PCL_FILTERS_VOXEL_GRID_OCCLUSION_ESTIMATION_H_
00043
00044 #include <pcl/filters/voxel_grid.h>
00045
00046 namespace pcl
00047 {
00055 template <typename PointT>
00056 class VoxelGridOcclusionEstimation: public VoxelGrid<PointT>
00057 {
00058 protected:
00059 using VoxelGrid<PointT>::min_b_;
00060 using VoxelGrid<PointT>::max_b_;
00061 using VoxelGrid<PointT>::div_b_;
00062 using VoxelGrid<PointT>::leaf_size_;
00063 using VoxelGrid<PointT>::inverse_leaf_size_;
00064
00065 typedef typename Filter<PointT>::PointCloud PointCloud;
00066 typedef typename PointCloud::Ptr PointCloudPtr;
00067 typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00068
00069 public:
00071 VoxelGridOcclusionEstimation ()
00072 {
00073 initialized_ = false;
00074 this->setSaveLeafLayout (true);
00075 }
00076
00078 virtual ~VoxelGridOcclusionEstimation ()
00079 {
00080 }
00081
00086 void
00087 initializeVoxelGrid ();
00088
00095 int
00096 occlusionEstimation (int& out_state,
00097 const Eigen::Vector3i& in_target_voxel);
00098
00108 int
00109 occlusionEstimation (int& out_state,
00110 std::vector<Eigen::Vector3i>& out_ray,
00111 const Eigen::Vector3i& in_target_voxel);
00112
00117 int
00118 occlusionEstimationAll (std::vector<Eigen::Vector3i>& occluded_voxels);
00119
00123 inline PointCloud
00124 getFilteredPointCloud () { return filtered_cloud_; }
00125
00126
00130 inline Eigen::Vector3f
00131 getMinBoundCoordinates () { return (b_min_.head<3> ()); }
00132
00136 inline Eigen::Vector3f
00137 getMaxBoundCoordinates () { return (b_max_.head<3> ()); }
00138
00144 inline Eigen::Vector4f
00145 getCentroidCoordinate (const Eigen::Vector3i& ijk)
00146 {
00147 int i,j,k;
00148 i = ((b_min_[0] < 0) ? (abs (min_b_[0]) + ijk[0]) : (ijk[0] - min_b_[0]));
00149 j = ((b_min_[1] < 0) ? (abs (min_b_[1]) + ijk[1]) : (ijk[1] - min_b_[1]));
00150 k = ((b_min_[2] < 0) ? (abs (min_b_[2]) + ijk[2]) : (ijk[2] - min_b_[2]));
00151
00152 Eigen::Vector4f xyz;
00153 xyz[0] = b_min_[0] + (leaf_size_[0] * 0.5f) + (static_cast<float> (i) * leaf_size_[0]);
00154 xyz[1] = b_min_[1] + (leaf_size_[1] * 0.5f) + (static_cast<float> (j) * leaf_size_[1]);
00155 xyz[2] = b_min_[2] + (leaf_size_[2] * 0.5f) + (static_cast<float> (k) * leaf_size_[2]);
00156 xyz[3] = 0;
00157 return xyz;
00158 }
00159
00160
00161
00162
00163
00164
00165
00166 protected:
00167
00174 float
00175 rayBoxIntersection (const Eigen::Vector4f& origin,
00176 const Eigen::Vector4f& direction);
00177
00186 int
00187 rayTraversal (const Eigen::Vector3i& target_voxel,
00188 const Eigen::Vector4f& origin,
00189 const Eigen::Vector4f& direction,
00190 const float t_min);
00191
00201 int
00202 rayTraversal (std::vector <Eigen::Vector3i>& out_ray,
00203 const Eigen::Vector3i& target_voxel,
00204 const Eigen::Vector4f& origin,
00205 const Eigen::Vector4f& direction,
00206 const float t_min);
00207
00212 inline float
00213 round (float d)
00214 {
00215 return static_cast<float> (floor (d + 0.5f));
00216 }
00217
00218
00224 inline Eigen::Vector3i
00225 getGridCoordinatesRound (float x, float y, float z)
00226 {
00227 return Eigen::Vector3i (static_cast<int> (round (x * inverse_leaf_size_[0])),
00228 static_cast<int> (round (y * inverse_leaf_size_[1])),
00229 static_cast<int> (round (z * inverse_leaf_size_[2])));
00230 }
00231
00232
00233 bool initialized_;
00234
00235 Eigen::Vector4f sensor_origin_;
00236 Eigen::Quaternionf sensor_orientation_;
00237
00238
00239 Eigen::Vector4f b_min_, b_max_;
00240
00241
00242 PointCloud filtered_cloud_;
00243 };
00244 }
00245
00246 #endif //#ifndef PCL_FILTERS_VOXEL_GRID_OCCLUSION_ESTIMATION_H_