Point Cloud Library (PCL)  1.10.1
octree_pointcloud_changedetector.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2011, Willow Garage, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Willow Garage, Inc. nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  * $Id$
37  */
38 
39 #pragma once
40 
41 #include <boost/shared_ptr.hpp>
42 
43 #include <pcl/octree/octree2buf_base.h>
44 #include <pcl/octree/octree_pointcloud.h>
45 
46 namespace pcl {
47 namespace octree {
48 
49 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
50 /** \brief @b Octree pointcloud change detector class
51  * \note This pointcloud octree class generate an octrees from a point cloud
52  * (zero-copy). It allows to detect new leaf nodes and serialize their point indices
53  * \note The octree pointcloud is initialized with its voxel resolution. Its bounding
54  * box is automatically adjusted or can be predefined.
55  * \tparam PointT type of point used in pointcloud
56  * \ingroup octree
57  * \author Julius Kammerl (julius@kammerl.de)
58  */
59 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
60 template <typename PointT,
61  typename LeafContainerT = OctreeContainerPointIndices,
62  typename BranchContainerT = OctreeContainerEmpty>
63 
65 : public OctreePointCloud<PointT,
66  LeafContainerT,
67  BranchContainerT,
68  Octree2BufBase<LeafContainerT, BranchContainerT>>
69 
70 {
71 
72 public:
73  using Ptr = shared_ptr<
75  using ConstPtr = shared_ptr<
77 
78  /** \brief Constructor.
79  * \param resolution_arg: octree resolution at lowest octree level
80  * */
81  OctreePointCloudChangeDetector(const double resolution_arg)
83  LeafContainerT,
84  BranchContainerT,
85  Octree2BufBase<LeafContainerT, BranchContainerT>>(resolution_arg)
86  {}
87 
88  /** \brief Get a indices from all leaf nodes that did not exist in previous buffer.
89  * \param indicesVector_arg: results are written to this vector of int indices
90  * \param minPointsPerLeaf_arg: minimum amount of points required within leaf node to
91  * become serialized.
92  * \return number of point indices
93  */
94  std::size_t
95  getPointIndicesFromNewVoxels(std::vector<int>& indicesVector_arg,
96  const int minPointsPerLeaf_arg = 0)
97  {
98 
99  std::vector<OctreeContainerPointIndices*> leaf_containers;
100  this->serializeNewLeafs(leaf_containers);
101 
102  for (const auto& leaf_container : leaf_containers) {
103  if (static_cast<int>(leaf_container->getSize()) >= minPointsPerLeaf_arg)
104  leaf_container->getPointIndices(indicesVector_arg);
105  }
106 
107  return (indicesVector_arg.size());
108  }
109 };
110 } // namespace octree
111 } // namespace pcl
112 
113 #define PCL_INSTANTIATE_OctreePointCloudChangeDetector(T) \
114  template class PCL_EXPORTS pcl::octree::OctreePointCloudChangeDetector<T>;
pcl
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
pcl::octree::OctreePointCloudChangeDetector::OctreePointCloudChangeDetector
OctreePointCloudChangeDetector(const double resolution_arg)
Constructor.
Definition: octree_pointcloud_changedetector.h:81
pcl::octree::OctreePointCloud
Octree pointcloud class
Definition: octree_pointcloud.h:73
pcl::octree::OctreePointCloudChangeDetector::Ptr
shared_ptr< OctreePointCloudChangeDetector< PointT, LeafContainerT, BranchContainerT > > Ptr
Definition: octree_pointcloud_changedetector.h:74
pcl::PointXYZRGB
A point structure representing Euclidean xyz coordinates, and the RGB color.
Definition: point_types.hpp:620
pcl::octree::Octree2BufBase
Octree double buffer class
Definition: octree2buf_base.h:201
pcl::octree::OctreePointCloud< PointInT, OctreeContainerPointIndices, OctreeContainerEmpty, Octree2BufBase< OctreeContainerPointIndices, OctreeContainerEmpty > >::ConstPtr
shared_ptr< const OctreePointCloud< PointInT, OctreeContainerPointIndices, OctreeContainerEmpty, Octree2BufBase< OctreeContainerPointIndices, OctreeContainerEmpty > > > ConstPtr
Definition: octree_pointcloud.h:105
pcl::octree::OctreePointCloudChangeDetector::getPointIndicesFromNewVoxels
std::size_t getPointIndicesFromNewVoxels(std::vector< int > &indicesVector_arg, const int minPointsPerLeaf_arg=0)
Get a indices from all leaf nodes that did not exist in previous buffer.
Definition: octree_pointcloud_changedetector.h:95
pcl::octree::OctreePointCloudChangeDetector
Octree pointcloud change detector class
Definition: octree_pointcloud_changedetector.h:64
pcl::octree::Octree2BufBase::serializeNewLeafs
void serializeNewLeafs(std::vector< LeafContainerT * > &leaf_container_vector_arg)
Outputs a vector of all DataT elements from leaf nodes, that do not exist in the previous octree buff...
Definition: octree2buf_base.hpp:337
pcl::shared_ptr
boost::shared_ptr< T > shared_ptr
Alias for boost::shared_ptr.
Definition: pcl_macros.h:108