RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
Compression.h
1/*
2Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the Universite de Sherbrooke nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28#ifndef COMPRESSION_H_
29#define COMPRESSION_H_
30
31#include "rtabmap/core/rtabmap_core_export.h" // DLL export/import defines
32
33#include <rtabmap/core/rvl_codec.h>
34#include <rtabmap/utilite/UThread.h>
35#include <opencv2/opencv.hpp>
36
37namespace rtabmap {
38
67class RTABMAP_CORE_EXPORT CompressionThread : public UThread
68{
69public:
75 CompressionThread(const cv::Mat & mat, const std::string & format = "");
81 CompressionThread(const cv::Mat & bytes, bool isImage);
83 const cv::Mat & getCompressedData() const {return compressedData_;}
85 cv::Mat & getUncompressedData() {return uncompressedData_;}
86protected:
87 virtual void mainLoop();
88private:
89 cv::Mat compressedData_;
90 cv::Mat uncompressedData_;
91 std::string format_;
92 bool image_;
93 bool compressMode_;
94};
95
97std::vector<unsigned char> RTABMAP_CORE_EXPORT compressImage(const cv::Mat & image, const std::string & format = ".png");
99cv::Mat RTABMAP_CORE_EXPORT compressImage2(const cv::Mat & image, const std::string & format = ".png");
100
102cv::Mat RTABMAP_CORE_EXPORT uncompressImage(const cv::Mat & bytes);
104cv::Mat RTABMAP_CORE_EXPORT uncompressImage(const std::vector<unsigned char> & bytes);
105
107std::vector<unsigned char> RTABMAP_CORE_EXPORT compressData(const cv::Mat & data);
109cv::Mat RTABMAP_CORE_EXPORT compressData2(const cv::Mat & data);
110
112cv::Mat RTABMAP_CORE_EXPORT uncompressData(const cv::Mat & bytes);
114cv::Mat RTABMAP_CORE_EXPORT uncompressData(const std::vector<unsigned char> & bytes);
116cv::Mat RTABMAP_CORE_EXPORT uncompressData(const unsigned char * bytes, unsigned long size);
117
119cv::Mat RTABMAP_CORE_EXPORT compressString(const std::string & str);
121std::string RTABMAP_CORE_EXPORT uncompressString(const cv::Mat & bytes);
122
127std::string RTABMAP_CORE_EXPORT compressedDepthFormat(const cv::Mat & bytes);
129std::string RTABMAP_CORE_EXPORT compressedDepthFormat(const std::vector<unsigned char> & bytes);
131std::string RTABMAP_CORE_EXPORT compressedDepthFormat(const unsigned char * bytes, size_t size);
132
133} /* namespace rtabmap */
134#endif /* COMPRESSION_H_ */
Background thread to compress or uncompress images and generic matrices.
Definition Compression.h:68
const cv::Mat & getCompressedData() const
Definition Compression.h:83
CompressionThread(const cv::Mat &mat, const std::string &format="")
Constructs a thread in compress mode.
CompressionThread(const cv::Mat &bytes, bool isImage)
Constructs a thread in uncompress mode.
cv::Mat & getUncompressedData()
Definition Compression.h:85
cv::Mat RTABMAP_CORE_EXPORT uncompressImage(const cv::Mat &bytes)
Decodes compressed image bytes to a @cv::Mat.
cv::Mat RTABMAP_CORE_EXPORT compressString(const std::string &str)
Compresses a null-terminated string using compressData2().
std::vector< unsigned char > RTABMAP_CORE_EXPORT compressImage(const cv::Mat &image, const std::string &format=".png")
Encodes image to a byte buffer (OpenCV imencode or RVL for depth).
std::string RTABMAP_CORE_EXPORT compressedDepthFormat(const cv::Mat &bytes)
Detects the compression format of depth image bytes.
cv::Mat RTABMAP_CORE_EXPORT uncompressData(const cv::Mat &bytes)
Restores a matrix compressed with compressData() or compressData2().
std::vector< unsigned char > RTABMAP_CORE_EXPORT compressData(const cv::Mat &data)
Compresses a matrix with zlib; appends rows, cols and type at the end.
std::string RTABMAP_CORE_EXPORT uncompressString(const cv::Mat &bytes)
Decompresses a string produced by compressString().
cv::Mat RTABMAP_CORE_EXPORT compressImage2(const cv::Mat &image, const std::string &format=".png")
Same as compressImage() but returns a CV_8UC1 row matrix.
cv::Mat RTABMAP_CORE_EXPORT compressData2(const cv::Mat &data)
Same as compressData() but returns a CV_8UC1 row matrix.