Loading...
Searching...
No Matches
organized_pointcloud_compression.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2011, Willow Garage, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*/
#pragma once
#include <pcl/pcl_macros.h>
#include <pcl/point_cloud.h>
#include <pcl/io/openni_camera/openni_shift_to_depth_conversion.h>
#include <vector>
namespace pcl
{
namespace io
{
/** \author Julius Kammerl (julius@kammerl.de)
*/
template<typename PointT>
class OrganizedPointCloudCompression
{
public:
using PointCloud = pcl::PointCloud<PointT>;
using PointCloudPtr = typename PointCloud::Ptr;
using PointCloudConstPtr = typename PointCloud::ConstPtr;
/** \brief Empty Constructor. */
OrganizedPointCloudCompression () = default;
/** \brief Empty deconstructor. */
virtual ~OrganizedPointCloudCompression () = default;
/** \brief Encode point cloud to output stream
* \param[in] cloud_arg: point cloud to be compressed
* \param[out] compressedDataOut_arg: binary output stream containing compressed data
* \param[in] doColorEncoding: encode color information (if available)
* \param[in] convertToMono: convert rgb to mono
* \param[in] pngLevel_arg: png compression level (default compression: -1)
* \param[in] bShowStatistics_arg: show statistics
*/
void encodePointCloud (const PointCloudConstPtr &cloud_arg,
std::ostream& compressedDataOut_arg,
bool doColorEncoding = false,
bool convertToMono = false,
bool bShowStatistics_arg = true,
int pngLevel_arg = -1);
/** \brief Encode raw disparity map and color image.
* \note Default values are configured according to the kinect/asus device specifications
* \param[in] disparityMap_arg: pointer to raw 16-bit disparity map
* \param[in] colorImage_arg: pointer to raw 8-bit rgb color image
* \param[in] width_arg: width of disparity map/color image
* \param[in] height_arg: height of disparity map/color image
* \param[out] compressedDataOut_arg: binary output stream containing compressed data
* \param[in] doColorEncoding: encode color information (if available)
* \param[in] convertToMono: convert rgb to mono
* \param[in] pngLevel_arg: png compression level (default compression: -1)
* \param[in] bShowStatistics_arg: show statistics
* \param[in] focalLength_arg focal length
* \param[in] disparityShift_arg disparity shift
* \param[in] disparityScale_arg disparity scaling
*/
void encodeRawDisparityMapWithColorImage ( std::vector<std::uint16_t>& disparityMap_arg,
std::vector<std::uint8_t>& colorImage_arg,
std::uint32_t width_arg,
std::uint32_t height_arg,
std::ostream& compressedDataOut_arg,
bool doColorEncoding = false,
bool convertToMono = false,
bool bShowStatistics_arg = true,
int pngLevel_arg = -1,
float focalLength_arg = 525.0f,
float disparityShift_arg = 174.825f,
float disparityScale_arg = -0.161175f);
/** \brief Decode point cloud from input stream
* \param[in] compressedDataIn_arg: binary input stream containing compressed data
* \param[out] cloud_arg: reference to decoded point cloud
* \param[in] bShowStatistics_arg: show compression statistics during decoding
* \return false if an I/O error occurred.
*/
bool decodePointCloud (std::istream& compressedDataIn_arg,
PointCloudPtr &cloud_arg,
bool bShowStatistics_arg = true);
protected:
/** \brief Analyze input point cloud and calculate the maximum depth and focal length
* \param[in] cloud_arg: input point cloud
* \param[out] maxDepth_arg: calculated maximum depth
* \param[out] focalLength_arg: estimated focal length
*/
void analyzeOrganizedCloud (PointCloudConstPtr cloud_arg,
float& maxDepth_arg,
float& focalLength_arg) const;
private:
// frame header identifier
static const char* frameHeaderIdentifier_;
//
openni_wrapper::ShiftToDepthConverter sd_converter_;
};
// define frame identifier
template<typename PointT>
const char* OrganizedPointCloudCompression<PointT>::frameHeaderIdentifier_ = "<PCL-ORG-COMPRESSED>";
}
}
openni_wrapper::ShiftToDepthConverter
This class provides conversion of the openni 11-bit shift data to depth;.
Definition openni_shift_to_depth_conversion.h:54
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition point_cloud.h:174
pcl::PointCloud::Ptr
shared_ptr< PointCloud< PointT > > Ptr
Definition point_cloud.h:414
pcl::PointCloud::ConstPtr
shared_ptr< const PointCloud< PointT > > ConstPtr
Definition point_cloud.h:415
pcl::io::OrganizedPointCloudCompression::PointCloudPtr
typename PointCloud::Ptr PointCloudPtr
Definition organized_pointcloud_compression.h:59
pcl::io::OrganizedPointCloudCompression::PointCloud
pcl::PointCloud< PointT > PointCloud
Definition organized_pointcloud_compression.h:58
pcl::io::OrganizedPointCloudCompression::~OrganizedPointCloudCompression
virtual ~OrganizedPointCloudCompression()=default
Empty deconstructor.
pcl::io::OrganizedPointCloudCompression::encodePointCloud
void encodePointCloud(const PointCloudConstPtr &cloud_arg, std::ostream &compressedDataOut_arg, bool doColorEncoding=false, bool convertToMono=false, bool bShowStatistics_arg=true, int pngLevel_arg=-1)
Encode point cloud to output stream.
Definition organized_pointcloud_compression.hpp:58
pcl::io::OrganizedPointCloudCompression::OrganizedPointCloudCompression
OrganizedPointCloudCompression()=default
Empty Constructor.
pcl::io::OrganizedPointCloudCompression::decodePointCloud
bool decodePointCloud(std::istream &compressedDataIn_arg, PointCloudPtr &cloud_arg, bool bShowStatistics_arg=true)
Decode point cloud from input stream.
Definition organized_pointcloud_compression.hpp:269
pcl::io::OrganizedPointCloudCompression::analyzeOrganizedCloud
void analyzeOrganizedCloud(PointCloudConstPtr cloud_arg, float &maxDepth_arg, float &focalLength_arg) const
Analyze input point cloud and calculate the maximum depth and focal length.
Definition organized_pointcloud_compression.hpp:400
pcl::io::OrganizedPointCloudCompression::PointCloudConstPtr
typename PointCloud::ConstPtr PointCloudConstPtr
Definition organized_pointcloud_compression.h:60
pcl::io::OrganizedPointCloudCompression::encodeRawDisparityMapWithColorImage
void encodeRawDisparityMapWithColorImage(std::vector< std::uint16_t > &disparityMap_arg, std::vector< std::uint8_t > &colorImage_arg, std::uint32_t width_arg, std::uint32_t height_arg, std::ostream &compressedDataOut_arg, bool doColorEncoding=false, bool convertToMono=false, bool bShowStatistics_arg=true, int pngLevel_arg=-1, float focalLength_arg=525.0f, float disparityShift_arg=174.825f, float disparityScale_arg=-0.161175f)
Encode raw disparity map and color image.
Definition organized_pointcloud_compression.hpp:152
pcl::io
Definition io.h:517
pcl
Definition convolution.h:46
pcl_macros.h
Defines all the PCL and non-PCL macros used.