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

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, for sets of at least two images the image at index 0 is always the left camera image, while 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 50 of file imageset.h.

#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,
  IMAGE_COLOR
}
 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...
 
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...
 
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...
 
void setExposureTime (int timeMicrosec)
 Sets the exposure time that was used for capturing the image set. More...
 
int getExposureTime () const
 Gets the exposure time in microseconds that was used for capturing the image set. More...
 
void setLastSyncPulse (int seconds, int microsec)
 Sets the timestamp of the last received sync pulse. More...
 
void getLastSyncPulse (int &seconds, int &microsec) const
 Gets the timestamp of the last received sync pulse. 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 = 4
 

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 68 of file imageset.h.

◆ ImageFormat_Deprecated

Deprecated:
Please use the new format constants in ImageFormat.

Definition at line 83 of file imageset.h.

◆ ImageType

Supported image types.

Enumerator
IMAGE_COLOR 

3rd color camera for devices where this is supported

Definition at line 91 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 43 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 164 of file imageset.cpp.

◆ 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 410 of file imageset.h.

◆ getBytesPerPixel() [1/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 188 of file imageset.cpp.

◆ getBytesPerPixel() [2/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 399 of file imageset.h.

◆ 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 349 of file imageset.h.

◆ getExposureTime()

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

Gets the exposure time in microseconds that was used for capturing the image set.

Returns
Exposure time in microseconds

Definition at line 509 of file imageset.h.

◆ getHeight()

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

Returns the height of each image.

Definition at line 234 of file imageset.h.

◆ getImageType()

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

Returns the ImageType of the specified channel.

Definition at line 197 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 214 of file imageset.cpp.

◆ getLastSyncPulse()

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

Gets the timestamp of the last received sync pulse.

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 532 of file imageset.h.

◆ getNumberOfImages()

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

Returns the number of images in this set.

Definition at line 431 of file imageset.h.

◆ getPixelData() [1/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 312 of file imageset.h.

◆ getPixelData() [2/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 299 of file imageset.h.

◆ getPixelFormat() [1/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 285 of file imageset.h.

◆ getPixelFormat() [2/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 272 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 320 of file imageset.h.

◆ getRowStride() [1/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 258 of file imageset.h.

◆ getRowStride() [2/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 245 of file imageset.h.

◆ getSequenceNumber()

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

Returns the sequence number for this image set.

Definition at line 327 of file imageset.h.

◆ getSubpixelFactor()

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

Gets the subpixel factor for this image set.

Definition at line 357 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 336 of file imageset.h.

◆ getWidth()

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

Returns the width of each image.

Definition at line 229 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 461 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 202 of file imageset.h.

◆ setExposureTime()

void visiontransfer::ImageSet::setExposureTime ( int  timeMicrosec)
inline

Sets the exposure time that was used for capturing the image set.

Parameters
timeMicrosecExposure time measured in microseconds

Definition at line 499 of file imageset.h.

◆ setHeight()

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

Sets a new width for both images.

Definition at line 122 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 240 of file imageset.cpp.

◆ setLastSyncPulse()

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

Sets the timestamp of the last received sync pulse.

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 520 of file imageset.h.

◆ setNumberOfImages()

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

Sets the number of valid images in this set.

Definition at line 438 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 161 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 143 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 172 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 131 of file imageset.h.

◆ setSequenceNumber()

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

Sets the sequence number for this image set.

Definition at line 179 of file imageset.h.

◆ setSubpixelFactor()

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

Sets the subpixel factor for this image set.

Definition at line 210 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 190 of file imageset.h.

◆ setWidth()

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

Sets a new width for both images.

Definition at line 117 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 39 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 106 of file imageset.cpp.


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