GPU-Accelerated Coverage  0.1.0
Compute coverage tours for known environment with articulated objects on GPU
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
gpu_coverage::Image Class Reference

Represents a 2D image. More...

#include <Image.h>

Public Member Functions

 Image (const aiTexture *const texture, const size_t &id)
 Constructor from aiTexture. More...
 
virtual ~Image ()
 
bool inUse () const
 Returns true if the image is in use. More...
 
void bindToUnit (const GLenum unit) const
 Bind this image to an OpenGL image unit. More...
 
const cv::Mat & image () const
 Returns this image as an OpenCV image. More...
 

Static Public Member Functions

static const Imageget (const std::string &path)
 Construct and return an Image from a file. More...
 
static void release (const Image *image)
 Release the image. More...
 

Protected Member Functions

 Image (const std::string &path)
 Protected constructor for loading image from file. More...
 
 Image (const int rows, const int cols, const int type, const unsigned char *const data=NULL)
 Protected constructor for creating image from raw data. More...
 

Protected Attributes

const size_t id
 Unique ID of this image.
 
cv::Mat mat
 OpenCV image.
 
size_t usage
 Internal usage counter, see get(), release() and inUse().
 
const std::string path
 File path from where the image was loaded.
 

Detailed Description

Represents a 2D image.

Constructor & Destructor Documentation

gpu_coverage::Image::Image ( const aiTexture *const  texture,
const size_t &  id 
)

Constructor from aiTexture.

Parameters
[in]textureThe Assimp aiTexture from where to load this image.
[in]idUnique ID for this image.

For creating an Image from a file instead of an Assimp texture, use the static get() method.

virtual gpu_coverage::Image::~Image ( )
virtual

.

gpu_coverage::Image::Image ( const std::string &  path)
protected

Protected constructor for loading image from file.

Parameters
[in]pathFile path from where to load the image.

Do not use this constructor, use the static get() method instead to allow for caching images.

gpu_coverage::Image::Image ( const int  rows,
const int  cols,
const int  type,
const unsigned char *const  data = NULL 
)
protected

Protected constructor for creating image from raw data.

Parameters
[in]rowsHeight of the image.
[in]colsWidth of the image.
[in]typeOpenCV image type.
[in]dataRaw data.

Member Function Documentation

void gpu_coverage::Image::bindToUnit ( const GLenum  unit) const

Bind this image to an OpenGL image unit.

Parameters
[in]unitThe ID of the image unit.
static const Image* gpu_coverage::Image::get ( const std::string &  path)
static

Construct and return an Image from a file.

Parameters
[in]pathFile path from where to load the image.
Returns
A new Image instance.

The image will be held in a cache. If this method gets called multiple times, the same instance will be returned from the cache and the usage counter will be incremented.

Call release() when the image is not needed anymore. If release() has been called the same number of times than the get() method, the Image will be deleted and removed from the cache.

const cv::Mat& gpu_coverage::Image::image ( ) const
inline

Returns this image as an OpenCV image.

Returns
OpenCV image.
bool gpu_coverage::Image::inUse ( ) const
inline

Returns true if the image is in use.

Returns
True if this image is in use.
See also
release()
static void gpu_coverage::Image::release ( const Image image)
static

Release the image.

Parameters
[in]imageThe image to release.

Calling this method decreases an internal usage counter. If release() has been called the same number of times than the get() method, the image will be deleted and removed from the cache.


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