libvisiontransfer  8.1.0
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
visiontransfer::ImageSet Class Reference

A set of one to three images, but usually two (the left camera image and the disparity map). One- and three-image modes can be enabled in the device configuration interface. More...

#include <visiontransfer/imageset.h>

Public Types

enum  ImageFormat { FORMAT_8_BIT_MONO, FORMAT_8_BIT_RGB, FORMAT_12_BIT_MONO }
 Image formats that can be transferred. More...
 
enum  ImageFormat_Deprecated { FORMAT_8_BIT = FORMAT_8_BIT_MONO, FORMAT_12_BIT = FORMAT_12_BIT_MONO }
 
enum  ImageType { IMAGE_UNDEFINED, IMAGE_LEFT, IMAGE_DISPARITY, IMAGE_RIGHT }
 Supported image types. More...
 

Public Member Functions

 ImageSet ()
 Default constructor creating an image set with no pixel data. More...
 
 ImageSet (const ImageSet &other)
 Copy constructor creating a shallow copy of the image set. More...
 
ImageSetoperator= (ImageSet const &other)
 
void setWidth (int w)
 Sets a new width for both images. More...
 
void setHeight (int h)
 Sets a new width for both images. More...
 
void setRowStride (int imageNumber, int stride)
 Sets a new row stride for the pixel data of one image. More...
 
void setPixelFormat (int imageNumber, ImageFormat format)
 Sets the pixel format for the given image. More...
 
void setPixelData (int imageNumber, unsigned char *pixelData)
 Sets the pixel data for the given image. More...
 
void setQMatrix (const float *q)
 Sets the pointer to the disparity-to-depth mapping matrix q. More...
 
void setSequenceNumber (unsigned int num)
 Sets the sequence number for this image set. More...
 
void setTimestamp (int seconds, int microsec)
 Sets the time at which this image set has been captured. More...
 
void setDisparityRange (int minimum, int maximum)
 Sets the value range for the disparity map contained in this image set. More...
 
void setSubpixelFactor (int subpixFact)
 Sets the subpixel factor for this image set. More...
 
 DEPRECATED ("Only compatible with two-image sets: use setNumberOfImages() and setIndexOf() instead") void setImageDisparityPair(bool dispPair)
 Sets whether this is a left camera image and disparity map set, or two raw camera images. More...
 
int getWidth () const
 Returns the width of each image. More...
 
int getHeight () const
 Returns the height of each image. More...
 
int getRowStride (int imageNumber) const
 Returns the row stride for the pixel data of one image. More...
 
int getRowStride (ImageType what) const
 Returns the row stride for the pixel data of one image. More...
 
ImageFormat getPixelFormat (int imageNumber) const
 Returns the pixel format for the given image. More...
 
ImageFormat getPixelFormat (ImageType what) const
 Returns the pixel format for the given image. More...
 
unsigned char * getPixelData (int imageNumber) const
 Returns the pixel data for the given image. More...
 
unsigned char * getPixelData (ImageType what) const
 Returns the pixel data for the given image. More...
 
const float * getQMatrix () const
 Returns a pointer to the disparity-to-depth mapping matrix q. More...
 
unsigned int getSequenceNumber () const
 Returns the sequence number for this image set. More...
 
void getTimestamp (int &seconds, int &microsec) const
 Returns the time at which this image set has been captured. More...
 
void getDisparityRange (int &minimum, int &maximum) const
 Gets the value range for the disparity map contained in this image set. If the image set does not contain any disparity data then the disparity range is undefined. More...
 
int getSubpixelFactor () const
 Gets the subpixel factor for this image set. More...
 
void writePgmFile (int imageNumber, const char *fileName) const
 Writes one image of the set to a PGM or PPM file. More...
 
bool isImageDisparityPair () const
 Returns true if this is a left camera image and disparity map pair. More...
 
void copyTo (ImageSet &dest)
 Makes a deep copy of this image set. More...
 
int getBytesPerPixel (int imageNumber) const
 Returns the number of bytes that are required to store one image pixel. More...
 
int getBitsPerPixel (int imageNumber) const
 Returns the number of bits that are required to store one image pixel. More...
 
int getBitsPerPixel (ImageType what) const
 
int getNumberOfImages () const
 Returns the number of images in this set. More...
 
void setNumberOfImages (int number)
 Sets the number of valid images in this set. More...
 
ImageType getImageType (int imageNumber) const
 Returns the ImageType of the specified channel. More...
 
int getIndexOf (ImageType what, bool throwIfNotFound=false) const
 Returns the index of a specific image type. More...
 
bool hasImageType (ImageType what) const
 Returns whether a left camera image is included in the enabled data. More...
 
void setIndexOf (ImageType what, int idx)
 Assign an image index to a specified ImageType, -1 to disable. More...
 
void toOpenCVImage (int imageNumber, cv::Mat &dest, bool convertRgbToBgr=true)
 Converts one image of the set to an OpenCV image. More...
 

Static Public Member Functions

static int getBitsPerPixel (ImageFormat format)
 
static int getBytesPerPixel (ImageFormat format)
 Returns the number of bytes that are required to store one image pixel with the given pixel format. More...
 

Static Public Attributes

static const int MAX_SUPPORTED_IMAGES = 3
 

Detailed Description

A set of one to three images, but usually two (the left camera image and the disparity map). One- and three-image modes can be enabled in the device configuration interface.

For backwards compatibility, the image at index 0 is always the left camera image, while for sets of as least two images, the one at index 1 is either the disparity map if in disparity processing mode, or the right image otherwise.

All images must be of equal width and height, but are allowed to have different pixel formats. Please note that the class does not manage the pixel data but only keeps pointers. You thus need to ensure that the pixel data remains valid for as long as this object persists.

Definition at line 38 of file imageset.h.

Member Enumeration Documentation

◆ ImageFormat

Image formats that can be transferred.

Enumerator
FORMAT_8_BIT_MONO 

8-bit greyscale format

FORMAT_8_BIT_RGB 

8-bit RGB format

FORMAT_12_BIT_MONO 

12-bit greyscale format plus 4 bits of padding (hence a total of 16 bits).

Definition at line 44 of file imageset.h.

◆ ImageFormat_Deprecated

Deprecated:
Please use the new format constants in ImageFormat.

Definition at line 59 of file imageset.h.

◆ ImageType

Supported image types.

Definition at line 67 of file imageset.h.

Constructor & Destructor Documentation

◆ ImageSet() [1/2]

visiontransfer::ImageSet::ImageSet ( )

Default constructor creating an image set with no pixel data.

Definition at line 31 of file imageset.cpp.

◆ ImageSet() [2/2]

visiontransfer::ImageSet::ImageSet ( const ImageSet other)

Copy constructor creating a shallow copy of the image set.

Definition at line 42 of file imageset.cpp.

Member Function Documentation

◆ copyTo()

void visiontransfer::ImageSet::copyTo ( ImageSet dest)

Makes a deep copy of this image set.

Definition at line 159 of file imageset.cpp.

◆ DEPRECATED()

visiontransfer::ImageSet::DEPRECATED ( "Only compatible with two-image sets: use setNumberOfImages() and setIndexOf() instead"  )

Sets whether this is a left camera image and disparity map set, or two raw camera images.

DEPRECATION NOTICE: Please use setNumberOfImages() and setIndexOf() for more comprehensive control of the images in the image set.

◆ getBitsPerPixel()

int visiontransfer::ImageSet::getBitsPerPixel ( int  imageNumber) const
inline

Returns the number of bits that are required to store one image pixel.

Parameters
imageNumberThe number of the image (0 ... getNumberOfImages()-1).

Definition at line 379 of file imageset.h.

◆ getBytesPerPixel() [1/2]

int visiontransfer::ImageSet::getBytesPerPixel ( int  imageNumber) const
inline

Returns the number of bytes that are required to store one image pixel.

Parameters
imageNumberThe number of the image (0 ... getNumberOfImages()-1).

Definition at line 368 of file imageset.h.

◆ getBytesPerPixel() [2/2]

int visiontransfer::ImageSet::getBytesPerPixel ( ImageFormat  format)
static

Returns the number of bytes that are required to store one image pixel with the given pixel format.

Definition at line 183 of file imageset.cpp.

◆ getDisparityRange()

void visiontransfer::ImageSet::getDisparityRange ( int &  minimum,
int &  maximum 
) const
inline

Gets the value range for the disparity map contained in this image set. If the image set does not contain any disparity data then the disparity range is undefined.

Parameters
minimumMinimum disparity value.
maximumMaximum disparity value.

Definition at line 320 of file imageset.h.

◆ getHeight()

int visiontransfer::ImageSet::getHeight ( ) const
inline

Returns the height of each image.

Definition at line 205 of file imageset.h.

◆ getImageType()

ImageSet::ImageType visiontransfer::ImageSet::getImageType ( int  imageNumber) const

Returns the ImageType of the specified channel.

Definition at line 192 of file imageset.cpp.

◆ getIndexOf()

int visiontransfer::ImageSet::getIndexOf ( ImageType  what,
bool  throwIfNotFound = false 
) const

Returns the index of a specific image type.

Parameters
whatImageType of the desired channel.
throwIfNotFoundThrow a runtime error instead of returning -1.
Returns
Returns the index of the specified type, or -1 if not found.

Definition at line 208 of file imageset.cpp.

◆ getNumberOfImages()

int visiontransfer::ImageSet::getNumberOfImages ( ) const
inline

Returns the number of images in this set.

Definition at line 400 of file imageset.h.

◆ getPixelData() [1/2]

unsigned char* visiontransfer::ImageSet::getPixelData ( int  imageNumber) const
inline

Returns the pixel data for the given image.

Parameters
imageNumberNumber of the image for which to receive the pixel data (0 ... getNumberOfImages()-1).

Please use getPixelData(ImageSet::ImageType) to access the data by their abstract role in lieu of their index in the set.

Definition at line 270 of file imageset.h.

◆ getPixelData() [2/2]

unsigned char* visiontransfer::ImageSet::getPixelData ( ImageType  what) const
inline

Returns the pixel data for the given image.

Parameters
whatImageType of the desired channel.

This function will throw an exception when the ImageType is not present in this set (use hasImageType(what) to check).

Definition at line 283 of file imageset.h.

◆ getPixelFormat() [1/2]

ImageFormat visiontransfer::ImageSet::getPixelFormat ( int  imageNumber) const
inline

Returns the pixel format for the given image.

Parameters
imageNumberNumber of the image for which to receive the pixel format (0 ... getNumberOfImages()-1).

Please use getPixelFormat(ImageSet::ImageType) to access the data by their abstract role in lieu of their index in the set.

Definition at line 243 of file imageset.h.

◆ getPixelFormat() [2/2]

ImageFormat visiontransfer::ImageSet::getPixelFormat ( ImageType  what) const
inline

Returns the pixel format for the given image.

Parameters
whatImageType of the desired channel.

This function will throw an exception when the ImageType is not present in this set (use hasImageType(what) to check).

Definition at line 256 of file imageset.h.

◆ getQMatrix()

const float* visiontransfer::ImageSet::getQMatrix ( ) const
inline

Returns a pointer to the disparity-to-depth mapping matrix q.

Definition at line 291 of file imageset.h.

◆ getRowStride() [1/2]

int visiontransfer::ImageSet::getRowStride ( int  imageNumber) const
inline

Returns the row stride for the pixel data of one image.

Parameters
imageNumberNumber of the image for which to obtain the row stride (0 ... getNumberOfImages()-1).

Please use getRowStride(ImageSet::ImageType) to access the data by their abstract role in lieu of their index in the set.

Definition at line 216 of file imageset.h.

◆ getRowStride() [2/2]

int visiontransfer::ImageSet::getRowStride ( ImageType  what) const
inline

Returns the row stride for the pixel data of one image.

Parameters
whatImageType of the desired channel.

This function will throw an exception when the ImageType is not present in this set (use hasImageType(what) to check).

Definition at line 229 of file imageset.h.

◆ getSequenceNumber()

unsigned int visiontransfer::ImageSet::getSequenceNumber ( ) const
inline

Returns the sequence number for this image set.

Definition at line 298 of file imageset.h.

◆ getSubpixelFactor()

int visiontransfer::ImageSet::getSubpixelFactor ( ) const
inline

Gets the subpixel factor for this image set.

Definition at line 328 of file imageset.h.

◆ getTimestamp()

void visiontransfer::ImageSet::getTimestamp ( int &  seconds,
int &  microsec 
) const
inline

Returns the time at which this image set has been captured.

Parameters
secondsThe time stamp with a resolution of one second.
microsecThe fractional seconds part of the time stamp with a resolution of 1 microsecond.

Definition at line 307 of file imageset.h.

◆ getWidth()

int visiontransfer::ImageSet::getWidth ( ) const
inline

Returns the width of each image.

Definition at line 200 of file imageset.h.

◆ hasImageType()

bool visiontransfer::ImageSet::hasImageType ( ImageType  what) const
inline

Returns whether a left camera image is included in the enabled data.

Definition at line 430 of file imageset.h.

◆ isImageDisparityPair()

bool visiontransfer::ImageSet::isImageDisparityPair ( ) const
inline

Returns true if this is a left camera image and disparity map pair.

DEPRECATION NOTICE: this is a legacy function; in case of image sets with one or three images, the result may not be as expected (this functions returns true only for the case of exactly two images: left image plus disparity image).

The new function hasImageType(ImageSet::ImageType) provides better granularity of what data are enabled and present.

Definition at line 353 of file imageset.h.

◆ setDisparityRange()

void visiontransfer::ImageSet::setDisparityRange ( int  minimum,
int  maximum 
)
inline

Sets the value range for the disparity map contained in this image set.

Parameters
minimumMinimum disparity value.
maximumMaximum disparity value.

Definition at line 175 of file imageset.h.

◆ setHeight()

void visiontransfer::ImageSet::setHeight ( int  h)
inline

Sets a new width for both images.

Definition at line 95 of file imageset.h.

◆ setIndexOf()

void visiontransfer::ImageSet::setIndexOf ( ImageType  what,
int  idx 
)

Assign an image index to a specified ImageType, -1 to disable.

Parameters
whatThe ImageType to assign a new image index to.
idxThe index of the specified ImageType inside the data of this ImageSet (-1 to disable).

Definition at line 230 of file imageset.cpp.

◆ setNumberOfImages()

void visiontransfer::ImageSet::setNumberOfImages ( int  number)
inline

Sets the number of valid images in this set.

Definition at line 407 of file imageset.h.

◆ setPixelData()

void visiontransfer::ImageSet::setPixelData ( int  imageNumber,
unsigned char *  pixelData 
)
inline

Sets the pixel data for the given image.

Parameters
imageNumberNumber of the image for which to set the pixel data (0 ... getNumberOfImages()-1).
pixelDataThe pixel data that shall be set.

Definition at line 134 of file imageset.h.

◆ setPixelFormat()

void visiontransfer::ImageSet::setPixelFormat ( int  imageNumber,
ImageFormat  format 
)
inline

Sets the pixel format for the given image.

Parameters
imageNumberNumber of the image for which to set the pixel format (0 ... getNumberOfImages()-1).
formatThe pixel format that shall be set.

Definition at line 116 of file imageset.h.

◆ setQMatrix()

void visiontransfer::ImageSet::setQMatrix ( const float *  q)
inline

Sets the pointer to the disparity-to-depth mapping matrix q.

No data is copied. The data which q is pointing to has to remain valid for as long as this object exists.

Definition at line 145 of file imageset.h.

◆ setRowStride()

void visiontransfer::ImageSet::setRowStride ( int  imageNumber,
int  stride 
)
inline

Sets a new row stride for the pixel data of one image.

Parameters
imageNumberNumber of the image for which to set the row stride (0 ... getNumberOfImages()-1).
strideThe row stride that shall be set.

Definition at line 104 of file imageset.h.

◆ setSequenceNumber()

void visiontransfer::ImageSet::setSequenceNumber ( unsigned int  num)
inline

Sets the sequence number for this image set.

Definition at line 152 of file imageset.h.

◆ setSubpixelFactor()

void visiontransfer::ImageSet::setSubpixelFactor ( int  subpixFact)
inline

Sets the subpixel factor for this image set.

Definition at line 183 of file imageset.h.

◆ setTimestamp()

void visiontransfer::ImageSet::setTimestamp ( int  seconds,
int  microsec 
)
inline

Sets the time at which this image set has been captured.

Parameters
secondsThe time stamp with a resolution of one second.
microsecThe fractional seconds part of the time stamp with a resolution of 1 microsecond.

Definition at line 163 of file imageset.h.

◆ setWidth()

void visiontransfer::ImageSet::setWidth ( int  w)
inline

Sets a new width for both images.

Definition at line 90 of file imageset.h.

◆ toOpenCVImage()

void visiontransfer::ImageSet::toOpenCVImage ( int  imageNumber,
cv::Mat &  dest,
bool  convertRgbToBgr = true 
)
inline

Converts one image of the set to an OpenCV image.

Parameters
imageNumberThe number of the image that shall be converted (0 ... getNumberOfImages()-1).
convertRgbToBgrIf true, then color images will converted from RGB to BGR in order to comply to OpenCV's convention.

For this method to be available, the OpenCV headers need to be included before including headers for libvisiontransfer.

Please note that only a shallow copy is performed. The ImageSet object must be kept alive for as long as the OpenCV image is in use.

Definition at line 27 of file imageset-opencv.h.

◆ writePgmFile()

void visiontransfer::ImageSet::writePgmFile ( int  imageNumber,
const char *  fileName 
) const

Writes one image of the set to a PGM or PPM file.

Parameters
imageNumberThe number of the image that shall be written.
Filename of the PGM or PPM file that shall be created.

Definition at line 101 of file imageset.cpp.


The documentation for this class was generated from the following files:
Nerian Vision Technologies