RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
rtabmap::CompressionThread Class Reference

Background thread to compress or uncompress images and generic matrices. More...

#include <Compression.h>

Inheritance diagram for rtabmap::CompressionThread:
Collaboration diagram for rtabmap::CompressionThread:

Public Member Functions

 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.
 
const cv::Mat & getCompressedData () const
 
cv::Mat & getUncompressedData ()
 
- Public Member Functions inherited from UThread
 UThread (Priority priority=kPNormal)
 
virtual ~UThread ()
 
void start ()
 
void kill ()
 
void join (bool killFirst=false)
 
void setPriority (Priority priority)
 
void setAffinity (int cpu=0)
 
bool isCreating () const
 
bool isRunning () const
 
bool isIdle () const
 
bool isKilled () const
 
Handle getThreadHandle () const
 
unsigned long getThreadId () const
 
- Public Member Functions inherited from UThreadC< void >
int Create (Handle *const &H=0, const bool &CreateDetached=false, const unsigned int &StackSize=0, const bool &CancelEnable=false, const bool &CancelAsync=false) const
 
int Create (unsigned long &ThreadId, Handle *const &H=0, const bool &CreateDetached=false, const unsigned int &StackSize=0, const bool &CancelEnable=false, const bool &CancelAsync=false) const
 
int Create (Handle *const &H=0, const bool &CreateDetached=false, const unsigned int &StackSize=0, const bool &CancelEnable=false, const bool &CancelAsync=false) const
 
int Create (unsigned long &ThreadId, Handle *const &H=0, const bool &CreateDetached=false, const unsigned int &StackSize=0, const bool &CancelEnable=false, const bool &CancelAsync=false) const
 

Protected Member Functions

virtual void mainLoop ()
 

Additional Inherited Members

- Public Types inherited from UThread
enum  Priority {
  kPLow , kPBelowNormal , kPNormal , kPAboveNormal ,
  kPRealTime
}
 
- Public Types inherited from UThreadC< void >
typedef THREAD_HANDLE Handle
 
typedef void(* Handler) ()
 
typedef THREAD_HANDLE Handle
 
typedef void(* Handler) ()
 
- Static Public Member Functions inherited from UThread
static unsigned long currentThreadId ()
 
- Static Public Member Functions inherited from UThreadC< void >
static int Create (const Handler &Function, Handle *const &H=0, const bool &CreateDetached=false, const unsigned int &StackSize=0, const bool &CancelEnable=false, const bool &CancelAsync=false)
 
static int Join (Handle H)
 
static int Kill (Handle H)
 
static int Detach (Handle H)
 
static int Create (const Handler &Function, Handle *const &H=0, const bool &CreateDetached=false, const unsigned int &StackSize=0, const bool &CancelEnable=false, const bool &CancelAsync=false)
 
static int Join (const Handle &H)
 
static int Kill (const Handle &H)
 
static int Detach (const Handle &H)
 
- Static Protected Member Functions inherited from UThreadC< void >
static void Exit ()
 
static void TestCancel ()
 
static Handle Self ()
 
static void Exit ()
 
static void TestCancel ()
 
static int Self ()
 

Detailed Description

Background thread to compress or uncompress images and generic matrices.

In compress mode, pass a source matrix to the constructor with an optional image format (".png", ".jpg", ".rvl", or empty for zlib data). In uncompress mode, pass compressed bytes and set isImage accordingly. Call UThread::start() then UThread::join() to obtain the result from getCompressedData() or getUncompressedData().

Example compression:

cv::Mat image;
CompressionThread ct(image, ".png");
ct.start();
ct.join();
cv::Mat bytes = ct.getCompressedData();
Background thread to compress or uncompress images and generic matrices.
Definition Compression.h:68

Example uncompression:

cv::Mat bytes;
CompressionThread ct(bytes, true);
ct.start();
ct.join();
cv::Mat image = ct.getUncompressedData();

Definition at line 67 of file Compression.h.

Constructor & Destructor Documentation

◆ CompressionThread() [1/2]

rtabmap::CompressionThread::CompressionThread ( const cv::Mat &  mat,
const std::string &  format = "" 
)

Constructs a thread in compress mode.

Parameters
matSource image or data matrix to compress.
formatImage format: ".png", ".jpg", ".rvl", or empty for zlib (compressData2).

◆ CompressionThread() [2/2]

rtabmap::CompressionThread::CompressionThread ( const cv::Mat &  bytes,
bool  isImage 
)

Constructs a thread in uncompress mode.

Parameters
bytesCompressed bytes (CV_8UC1).
isImageIf true, decode as image; otherwise decode as zlib data.

Member Function Documentation

◆ getCompressedData()

const cv::Mat & rtabmap::CompressionThread::getCompressedData ( ) const
inline
Returns
Compressed output (CV_8UC1), valid after compress mode completes.

Definition at line 83 of file Compression.h.

◆ getUncompressedData()

cv::Mat & rtabmap::CompressionThread::getUncompressedData ( )
inline
Returns
Uncompressed output, valid after uncompress mode completes.

Definition at line 85 of file Compression.h.

◆ mainLoop()

virtual void rtabmap::CompressionThread::mainLoop ( )
protectedvirtual

Pure virtual method mainLoop(). The inner loop of the thread. This method is called repetitively until the thread is killed. Note that if kill() is called in mainLoopBegin(), mainLoop() is not called, terminating immediately the thread.

See also
mainLoop()
kill()

Implements UThread.


The documentation for this class was generated from the following file: