40 #include <pcl/octree/octree2buf_base.h>
41 #include <pcl/octree/octree_pointcloud.h>
42 #include "entropy_range_coder.h"
43 #include "color_coding.h"
44 #include "point_coding.h"
46 #include "compression_profiles.h"
76 using Ptr = shared_ptr<OctreePointCloudCompression<PointT, LeafT, BranchT, OctreeT> >;
77 using ConstPtr = shared_ptr<const OctreePointCloudCompression<PointT, LeafT, BranchT, OctreeT> >;
97 bool showStatistics_arg =
false,
98 const double pointResolution_arg = 0.001,
99 const double octreeResolution_arg = 0.01,
100 bool doVoxelGridDownDownSampling_arg =
false,
101 const unsigned int iFrameRate_arg = 30,
102 bool doColorEncoding_arg =
true,
103 const unsigned char colorBitResolution_arg = 6) :
108 do_voxel_grid_enDecoding_ (doVoxelGridDownDownSampling_arg), i_frame_rate_ (iFrameRate_arg),
110 do_color_encoding_ (doColorEncoding_arg), b_show_statistics_ (showStatistics_arg),
111 selected_profile_(compressionProfile_arg),
112 point_resolution_(pointResolution_arg), octree_resolution_(octreeResolution_arg),
113 color_bit_resolution_(colorBitResolution_arg)
135 point_coder_.setPrecision (
static_cast<float> (selectedProfile.
pointResolution));
143 point_coder_.setPrecision (
static_cast<float> (point_resolution_));
144 color_coder_.setBitDepth (color_bit_resolution_);
147 if (point_coder_.getPrecision () == this->getResolution ())
149 do_voxel_grid_enDecoding_ =
true;
169 if (output_ != cloud_arg)
189 encodePointCloud (
const PointCloudConstPtr &cloud_arg, std::ostream& compressed_tree_data_out_arg);
197 decodePointCloud (std::istream& compressed_tree_data_in_arg, PointCloudPtr &cloud_arg);
205 writeFrameHeader (std::ostream& compressed_tree_data_out_arg);
211 readFrameHeader (std::istream& compressed_tree_data_in_arg);
217 syncToHeader (std::istream& compressed_tree_data_in_arg);
223 entropyEncoding (std::ostream& compressed_tree_data_out_arg);
229 entropyDecoding (std::istream& compressed_tree_data_in_arg);
236 serializeTreeCallback (LeafT &leaf_arg,
const OctreeKey& key_arg)
override;
243 deserializeTreeCallback (LeafT&,
const OctreeKey& key_arg)
override;
267 bool do_voxel_grid_enDecoding_{
false};
268 std::uint32_t i_frame_rate_{0};
269 std::uint32_t i_frame_counter_{0};
270 std::uint32_t frame_ID_{0};
271 std::uint64_t point_count_{0};
274 bool do_color_encoding_{
false};
275 bool cloud_with_color_{
false};
276 bool data_with_color_{
false};
277 unsigned char point_color_offset_{0};
280 bool b_show_statistics_{
false};
281 std::uint64_t compressed_point_data_len_{0};
282 std::uint64_t compressed_color_data_len_{0};
292 std::size_t object_count_{0};
297 template<
typename Po
intT,
typename LeafT,
typename BranchT,
typename OctreeT>
298 const char* OctreePointCloudCompression<PointT, LeafT, BranchT, OctreeT>::frame_header_identifier_ =
"<PCL-OCT-COMPRESSED>";
PointCloud represents the base class in PCL for storing collections of 3D points.
StaticRangeCoder compression class
Octree pointcloud compression class
shared_ptr< OctreePointCloudCompression< PointT, LeafT, BranchT, OctreeT > > Ptr
ColorCoding< PointT > color_coder_
Color coding instance.
const compression_Profiles_e selected_profile_
static const char * frame_header_identifier_
~OctreePointCloudCompression() override=default
Empty deconstructor.
std::vector< unsigned int >::const_iterator point_count_data_vector_iterator_
Iterator on points per voxel vector.
PointCoding< PointT > point_coder_
Point coding instance.
void addPointIdx(const uindex_t pointIdx_arg) override
Add point at index from input pointcloud dataset to octree.
typename OctreePointCloud< PointT, LeafT, BranchT, OctreeT >::PointCloud PointCloud
typename OctreeT::LeafNode LeafNode
StaticRangeCoder entropy_coder_
Static range coder instance.
typename OctreePointCloud< PointT, LeafT, BranchT, OctreeT >::PointCloudConstPtr PointCloudConstPtr
void setOutputCloud(const PointCloudPtr &cloud_arg)
Provide a pointer to the output data set.
const double point_resolution_
PointCloudPtr getOutputCloud() const
Get a pointer to the output point cloud dataset.
OctreePointCloudCompression(compression_Profiles_e compressionProfile_arg=MED_RES_ONLINE_COMPRESSION_WITH_COLOR, bool showStatistics_arg=false, const double pointResolution_arg=0.001, const double octreeResolution_arg=0.01, bool doVoxelGridDownDownSampling_arg=false, const unsigned int iFrameRate_arg=30, bool doColorEncoding_arg=true, const unsigned char colorBitResolution_arg=6)
Constructor.
std::vector< char > binary_tree_data_vector_
Vector for storing binary tree structure.
const unsigned char color_bit_resolution_
void initialization()
Initialize globals.
shared_ptr< const OctreePointCloudCompression< PointT, LeafT, BranchT, OctreeT > > ConstPtr
PointCloudPtr output_
Pointer to output point cloud dataset.
std::vector< unsigned int > point_count_data_vector_
Vector for storing points per voxel information
typename OctreePointCloud< PointT, LeafT, BranchT, OctreeT >::PointCloudPtr PointCloudPtr
const double octree_resolution_
typename OctreeT::BranchNode BranchNode
Octree double buffer class
Octree container class that does not store any information.
Octree container class that does store a vector of point indices.
Abstract octree leaf class
typename PointCloud::Ptr PointCloudPtr
typename PointCloud::ConstPtr PointCloudConstPtr
virtual void addPointIdx(uindex_t point_idx_arg)
Add point at index from input pointcloud dataset to octree.
const struct configurationProfile_t compressionProfiles_[COMPRESSION_PROFILE_COUNT]
detail::int_type_t< detail::index_type_size, false > uindex_t
Type used for an unsigned index in PCL.
A point structure representing Euclidean xyz coordinates, and the RGB color.
bool doVoxelGridDownSampling
const double octreeResolution
const unsigned char colorBitResolution