libvisiontransfer  6.1.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ImagePair Class Reference

A set of two images, which are usually the left camera image and the disparity map. More...

#include <visiontransfer/imagepair.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 = ImageFormat::FORMAT_8_BIT_MONO, FORMAT_12_BIT = ImageFormat::FORMAT_12_BIT_MONO }
 

Public Member Functions

 ImagePair ()
 Default constructor creating an image pair with no pixel data. More...
 
 ImagePair (const ImagePair &other)
 Copy constructor creating a shallow copy of the image pair. More...
 
ImagePairoperator= (ImagePair 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 pair. More...
 
void setTimestamp (int seconds, int microsec)
 Sets the time at which this image pair has been captured. More...
 
void setDisparityRange (int minimum, int maximum)
 Sets the value range for the disparity map contained in this image pair. More...
 
void setImageDisparityPair (bool dispPair)
 Sets whether this is a left camera image and disparity map pair, 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...
 
ImageFormat getPixelFormat (int imageNumber) 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...
 
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 pair. More...
 
void getTimestamp (int &seconds, int &microsec) const
 Returns the time at which this image pair has been captured. More...
 
void getDisparityRange (int &minimum, int &maximum) const
 Gets the value range for the disparity map contained in this image pair. If the image pair does not contain any disparity data then the disparity range is undefined. More...
 
void writePgmFile (int imageNumber, const char *fileName) const
 Writes one image of the pair 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 (ImagePair &dest)
 Makes a deep copy of this image pair. More...
 
int getBytesPerPixel (int imageNumber) const
 Returns the number of bytes that are required to store one image pixel. More...
 
void toOpenCVImage (int imageNumber, cv::Mat &dest, bool convertRgbToBgr=true)
 Converts one image of the pair to an OpenCV image. More...
 

Static Public Member Functions

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

Detailed Description

A set of two images, which are usually the left camera image and the disparity map.

Both images must be of equal width and height, but are allowed to have a 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 31 of file imagepair.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 36 of file imagepair.h.

◆ ImageFormat_Deprecated

Deprecated:
Please use the new format constants in ImageFormat.

Definition at line 51 of file imagepair.h.

Constructor & Destructor Documentation

◆ ImagePair() [1/2]

ImagePair::ImagePair ( )

Default constructor creating an image pair with no pixel data.

Definition at line 27 of file imagepair.cpp.

◆ ImagePair() [2/2]

ImagePair::ImagePair ( const ImagePair other)

Copy constructor creating a shallow copy of the image pair.

Definition at line 39 of file imagepair.cpp.

Member Function Documentation

◆ copyTo()

void ImagePair::copyTo ( ImagePair dest)

Makes a deep copy of this image pair.

Definition at line 142 of file imagepair.cpp.

◆ getBytesPerPixel() [1/2]

int ImagePair::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 or 1).

Definition at line 277 of file imagepair.h.

◆ getBytesPerPixel() [2/2]

int ImagePair::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 166 of file imagepair.cpp.

◆ getDisparityRange()

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

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

Parameters
minimumMinimum disparity value.
maximumMaximum disparity value.

Definition at line 245 of file imagepair.h.

◆ getHeight()

int ImagePair::getHeight ( ) const
inline

Returns the height of each image.

Definition at line 178 of file imagepair.h.

◆ getPixelData()

unsigned char* ImagePair::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 or 1).

Definition at line 208 of file imagepair.h.

◆ getPixelFormat()

ImageFormat ImagePair::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 or 1).

Definition at line 197 of file imagepair.h.

◆ getQMatrix()

const float* ImagePair::getQMatrix ( ) const
inline

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

Definition at line 216 of file imagepair.h.

◆ getRowStride()

int ImagePair::getRowStride ( int  imageNumber) const
inline

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

Parameters
imageNumberNumber of the image for which to receive the row stride (0 or 1).

Definition at line 186 of file imagepair.h.

◆ getSequenceNumber()

unsigned int ImagePair::getSequenceNumber ( ) const
inline

Returns the sequence number for this image pair.

Definition at line 223 of file imagepair.h.

◆ getTimestamp()

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

Returns the time at which this image pair 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 232 of file imagepair.h.

◆ getWidth()

int ImagePair::getWidth ( ) const
inline

Returns the width of each image.

Definition at line 173 of file imagepair.h.

◆ isImageDisparityPair()

bool ImagePair::isImageDisparityPair ( ) const
inline

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

Definition at line 262 of file imagepair.h.

◆ setDisparityRange()

void ImagePair::setDisparityRange ( int  minimum,
int  maximum 
)
inline

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

Parameters
minimumMinimum disparity value.
maximumMaximum disparity value.

Definition at line 157 of file imagepair.h.

◆ setHeight()

void ImagePair::setHeight ( int  h)
inline

Sets a new width for both images.

Definition at line 77 of file imagepair.h.

◆ setImageDisparityPair()

void ImagePair::setImageDisparityPair ( bool  dispPair)
inline

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

Definition at line 166 of file imagepair.h.

◆ setPixelData()

void ImagePair::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 or 1).
pixelDataThe pixel data that shall be set.

Definition at line 116 of file imagepair.h.

◆ setPixelFormat()

void ImagePair::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 or 1).
formatThe pixel format that shall be set.

Definition at line 98 of file imagepair.h.

◆ setQMatrix()

void ImagePair::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 127 of file imagepair.h.

◆ setRowStride()

void ImagePair::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 or 1).
strideThe row stride that shall be set.

Definition at line 86 of file imagepair.h.

◆ setSequenceNumber()

void ImagePair::setSequenceNumber ( unsigned int  num)
inline

Sets the sequence number for this image pair.

Definition at line 134 of file imagepair.h.

◆ setTimestamp()

void ImagePair::setTimestamp ( int  seconds,
int  microsec 
)
inline

Sets the time at which this image pair 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 145 of file imagepair.h.

◆ setWidth()

void ImagePair::setWidth ( int  w)
inline

Sets a new width for both images.

Definition at line 72 of file imagepair.h.

◆ toOpenCVImage()

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

Converts one image of the pair to an OpenCV image.

Parameters
imageNumberThe number of the image that shall be converted (0 or 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 ImagePair object must be kept alive until for as long as the OpenCV image is in use.

Definition at line 25 of file imagepair-opencv.h.

◆ writePgmFile()

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

Writes one image of the pair 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 93 of file imagepair.cpp.


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