Point Cloud Library (PCL)
1.7.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2010-2011, Willow Garage, Inc. 00006 * 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * * Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * * Redistributions in binary form must reproduce the above 00016 * copyright notice, this list of conditions and the following 00017 * disclaimer in the documentation and/or other materials provided 00018 * with the distribution. 00019 * * Neither the name of Willow Garage, Inc. nor the names of its 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00032 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00033 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 * $Id$ 00037 */ 00038 00039 #ifndef PCL_ORGANIZED_POINT_COMPRESSION_H_ 00040 #define PCL_ORGANIZED_POINT_COMPRESSION_H_ 00041 00042 #include <pcl/pcl_macros.h> 00043 #include <pcl/point_cloud.h> 00044 00045 #include <pcl/common/boost.h> 00046 #include <pcl/common/eigen.h> 00047 #include <pcl/common/common.h> 00048 #include <pcl/common/io.h> 00049 00050 #include <pcl/io/openni_camera/openni_shift_to_depth_conversion.h> 00051 00052 #include <vector> 00053 00054 namespace pcl 00055 { 00056 namespace io 00057 { 00058 /** \author Julius Kammerl (julius@kammerl.de) 00059 */ 00060 template<typename PointT> 00061 class OrganizedPointCloudCompression 00062 { 00063 public: 00064 typedef pcl::PointCloud<PointT> PointCloud; 00065 typedef boost::shared_ptr<PointCloud> PointCloudPtr; 00066 typedef boost::shared_ptr<const PointCloud> PointCloudConstPtr; 00067 00068 /** \brief Empty Constructor. */ 00069 OrganizedPointCloudCompression () 00070 { 00071 } 00072 00073 /** \brief Empty deconstructor. */ 00074 virtual ~OrganizedPointCloudCompression () 00075 { 00076 } 00077 00078 /** \brief Encode point cloud to output stream 00079 * \param[in] cloud_arg: point cloud to be compressed 00080 * \param[out] compressedDataOut_arg: binary output stream containing compressed data 00081 * \param[in] doColorEncoding: encode color information (if available) 00082 * \param[in] convertToMono: convert rgb to mono 00083 * \param[in] pngLevel_arg: png compression level (default compression: -1) 00084 * \param[in] bShowStatistics_arg: show statistics 00085 */ 00086 void encodePointCloud (const PointCloudConstPtr &cloud_arg, 00087 std::ostream& compressedDataOut_arg, 00088 bool doColorEncoding = false, 00089 bool convertToMono = false, 00090 bool bShowStatistics_arg = true, 00091 int pngLevel_arg = -1); 00092 00093 /** \brief Encode raw disparity map and color image. 00094 * \note Default values are configured according to the kinect/asus device specifications 00095 * \param[in] disparityMap_arg: pointer to raw 16-bit disparity map 00096 * \param[in] disparityMap_arg: pointer to raw 8-bit rgb color image 00097 * \param[in] width_arg: width of disparity map/color image 00098 * \param[in] height_arg: height of disparity map/color image 00099 * \param[out] compressedDataOut_arg: binary output stream containing compressed data 00100 * \param[in] doColorEncoding: encode color information (if available) 00101 * \param[in] convertToMono: convert rgb to mono 00102 * \param[in] pngLevel_arg: png compression level (default compression: -1) 00103 * \param[in] bShowStatistics_arg: show statistics 00104 * \param[in] focalLength_arg focal length 00105 * \param[in] disparityShift_arg disparity shift 00106 * \param[in] disparityScale_arg disparity scaling 00107 */ 00108 void encodeRawDisparityMapWithColorImage ( std::vector<uint16_t>& disparityMap_arg, 00109 std::vector<uint8_t>& colorImage_arg, 00110 uint32_t width_arg, 00111 uint32_t height_arg, 00112 std::ostream& compressedDataOut_arg, 00113 bool doColorEncoding = false, 00114 bool convertToMono = false, 00115 bool bShowStatistics_arg = true, 00116 int pngLevel_arg = -1, 00117 float focalLength_arg = 525.0f, 00118 float disparityShift_arg = 174.825f, 00119 float disparityScale_arg = -0.161175f); 00120 00121 /** \brief Decode point cloud from input stream 00122 * \param[in] compressedDataIn_arg: binary input stream containing compressed data 00123 * \param[out] cloud_arg: reference to decoded point cloud 00124 * \param[in] bShowStatistics_arg: show compression statistics during decoding 00125 * \return false if an I/O error occured. 00126 */ 00127 bool decodePointCloud (std::istream& compressedDataIn_arg, 00128 PointCloudPtr &cloud_arg, 00129 bool bShowStatistics_arg = true); 00130 00131 protected: 00132 /** \brief Analyze input point cloud and calculate the maximum depth and focal length 00133 * \param[in] cloud_arg: input point cloud 00134 * \param[out] maxDepth_arg: calculated maximum depth 00135 * \param[out] focalLength_arg: estimated focal length 00136 */ 00137 void analyzeOrganizedCloud (PointCloudConstPtr cloud_arg, 00138 float& maxDepth_arg, 00139 float& focalLength_arg) const; 00140 00141 private: 00142 // frame header identifier 00143 static const char* frameHeaderIdentifier_; 00144 00145 // 00146 openni_wrapper::ShiftToDepthConverter sd_converter_; 00147 }; 00148 00149 // define frame identifier 00150 template<typename PointT> 00151 const char* OrganizedPointCloudCompression<PointT>::frameHeaderIdentifier_ = "<PCL-ORG-COMPRESSED>"; 00152 } 00153 } 00154 00155 #endif