libvisiontransfer
10.8.0
|
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>
Classes | |
class | Pimpl |
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... | |
ImageSet & | operator= (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 µsec) 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 µsec) 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 |
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 74 of file imageset.h.
ImageFormat
. Definition at line 89 of file imageset.h.
Supported image types.
Enumerator | |
---|---|
IMAGE_COLOR | 3rd color camera for devices where this is supported |
Definition at line 97 of file imageset.h.
visiontransfer::ImageSet::ImageSet | ( | ) |
Default constructor creating an image set with no pixel data.
Definition at line 466 of file imageset.cpp.
visiontransfer::ImageSet::ImageSet | ( | const ImageSet & | other | ) |
Copy constructor creating a shallow copy of the image set.
Definition at line 471 of file imageset.cpp.
void visiontransfer::ImageSet::copyTo | ( | ImageSet & | dest | ) |
Makes a deep copy of this image set.
Definition at line 585 of file imageset.cpp.
int visiontransfer::ImageSet::getBitsPerPixel | ( | int | imageNumber | ) | const |
Returns the number of bits that are required to store one image pixel.
imageNumber | The number of the image (0 ... getNumberOfImages()-1). |
Definition at line 593 of file imageset.cpp.
|
static |
Returns the number of bytes that are required to store one image pixel with the given pixel format.
Definition at line 658 of file imageset.cpp.
int visiontransfer::ImageSet::getBytesPerPixel | ( | int | imageNumber | ) | const |
Returns the number of bytes that are required to store one image pixel.
imageNumber | The number of the image (0 ... getNumberOfImages()-1). |
Definition at line 589 of file imageset.cpp.
void visiontransfer::ImageSet::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.
minimum | Minimum disparity value. |
maximum | Maximum disparity value. |
Definition at line 573 of file imageset.cpp.
int visiontransfer::ImageSet::getExposureTime | ( | ) | const |
Gets the exposure time in microseconds that was used for capturing the image set.
Definition at line 635 of file imageset.cpp.
int visiontransfer::ImageSet::getHeight | ( | ) | const |
Returns the height of each image.
Definition at line 533 of file imageset.cpp.
ImageSet::ImageType visiontransfer::ImageSet::getImageType | ( | int | imageNumber | ) | const |
Returns the ImageType of the specified channel.
Definition at line 609 of file imageset.cpp.
int visiontransfer::ImageSet::getIndexOf | ( | ImageSet::ImageType | what, |
bool | throwIfNotFound = false |
||
) | const |
Returns the index of a specific image type.
what | ImageType of the desired channel. |
throwIfNotFound | Throw a runtime error instead of returning -1. |
Definition at line 613 of file imageset.cpp.
void visiontransfer::ImageSet::getLastSyncPulse | ( | int & | seconds, |
int & | microsec | ||
) | const |
Gets the timestamp of the last received sync pulse.
seconds | The time stamp with a resolution of one second. |
microsec | The fractional seconds part of the time stamp with a resolution of 1 microsecond. |
Definition at line 643 of file imageset.cpp.
int visiontransfer::ImageSet::getNumberOfImages | ( | ) | const |
Returns the number of images in this set.
Definition at line 601 of file imageset.cpp.
unsigned char * visiontransfer::ImageSet::getPixelData | ( | ImageSet::ImageType | what | ) | const |
Returns the pixel data for the given image.
what | ImageType 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 557 of file imageset.cpp.
unsigned char * visiontransfer::ImageSet::getPixelData | ( | int | imageNumber | ) | const |
Returns the pixel data for the given image.
imageNumber | Number 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 553 of file imageset.cpp.
ImageSet::ImageFormat visiontransfer::ImageSet::getPixelFormat | ( | ImageSet::ImageType | what | ) | const |
Returns the pixel format for the given image.
what | ImageType 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 549 of file imageset.cpp.
ImageSet::ImageFormat visiontransfer::ImageSet::getPixelFormat | ( | int | imageNumber | ) | const |
Returns the pixel format for the given image.
imageNumber | Number 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 545 of file imageset.cpp.
const float * visiontransfer::ImageSet::getQMatrix | ( | ) | const |
Returns a pointer to the disparity-to-depth mapping matrix q.
Definition at line 561 of file imageset.cpp.
int visiontransfer::ImageSet::getRowStride | ( | ImageSet::ImageType | what | ) | const |
Returns the row stride for the pixel data of one image.
what | ImageType 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 541 of file imageset.cpp.
int visiontransfer::ImageSet::getRowStride | ( | int | imageNumber | ) | const |
Returns the row stride for the pixel data of one image.
imageNumber | Number 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 537 of file imageset.cpp.
unsigned int visiontransfer::ImageSet::getSequenceNumber | ( | ) | const |
Returns the sequence number for this image set.
Definition at line 565 of file imageset.cpp.
int visiontransfer::ImageSet::getSubpixelFactor | ( | ) | const |
Gets the subpixel factor for this image set.
Definition at line 577 of file imageset.cpp.
void visiontransfer::ImageSet::getTimestamp | ( | int & | seconds, |
int & | microsec | ||
) | const |
Returns the time at which this image set has been captured.
seconds | The time stamp with a resolution of one second. |
microsec | The fractional seconds part of the time stamp with a resolution of 1 microsecond. |
Definition at line 569 of file imageset.cpp.
int visiontransfer::ImageSet::getWidth | ( | ) | const |
Returns the width of each image.
Definition at line 529 of file imageset.cpp.
bool visiontransfer::ImageSet::hasImageType | ( | ImageSet::ImageType | what | ) | const |
Returns whether a left camera image is included in the enabled data.
Definition at line 617 of file imageset.cpp.
void visiontransfer::ImageSet::setDisparityRange | ( | int | minimum, |
int | maximum | ||
) |
Sets the value range for the disparity map contained in this image set.
minimum | Minimum disparity value. |
maximum | Maximum disparity value. |
Definition at line 517 of file imageset.cpp.
void visiontransfer::ImageSet::setExposureTime | ( | int | timeMicrosec | ) |
Sets the exposure time that was used for capturing the image set.
timeMicrosec | Exposure time measured in microseconds |
Definition at line 631 of file imageset.cpp.
void visiontransfer::ImageSet::setHeight | ( | int | h | ) |
Sets a new width for both images.
Definition at line 489 of file imageset.cpp.
void visiontransfer::ImageSet::setIndexOf | ( | ImageSet::ImageType | what, |
int | idx | ||
) |
Assign an image index to a specified ImageType, -1 to disable.
what | The ImageType to assign a new image index to. |
idx | The index of the specified ImageType inside the data of this ImageSet (-1 to disable). |
Definition at line 621 of file imageset.cpp.
void visiontransfer::ImageSet::setLastSyncPulse | ( | int | seconds, |
int | microsec | ||
) |
Sets the timestamp of the last received sync pulse.
seconds | The time stamp with a resolution of one second. |
microsec | The fractional seconds part of the time stamp with a resolution of 1 microsecond. |
Definition at line 639 of file imageset.cpp.
void visiontransfer::ImageSet::setNumberOfImages | ( | int | number | ) |
Sets the number of valid images in this set.
Definition at line 605 of file imageset.cpp.
void visiontransfer::ImageSet::setPixelData | ( | int | imageNumber, |
unsigned char * | pixelData | ||
) |
Sets the pixel data for the given image.
imageNumber | Number of the image for which to set the pixel data (0 ... getNumberOfImages()-1). |
pixelData | The pixel data that shall be set. |
Definition at line 501 of file imageset.cpp.
void visiontransfer::ImageSet::setPixelFormat | ( | int | imageNumber, |
ImageSet::ImageFormat | format | ||
) |
Sets the pixel format for the given image.
imageNumber | Number of the image for which to set the pixel format (0 ... getNumberOfImages()-1). |
format | The pixel format that shall be set. |
Definition at line 497 of file imageset.cpp.
void visiontransfer::ImageSet::setQMatrix | ( | const float * | q | ) |
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 505 of file imageset.cpp.
void visiontransfer::ImageSet::setRowStride | ( | int | imageNumber, |
int | stride | ||
) |
Sets a new row stride for the pixel data of one image.
imageNumber | Number of the image for which to set the row stride (0 ... getNumberOfImages()-1). |
stride | The row stride that shall be set. |
Definition at line 493 of file imageset.cpp.
void visiontransfer::ImageSet::setSequenceNumber | ( | unsigned int | num | ) |
Sets the sequence number for this image set.
Definition at line 509 of file imageset.cpp.
void visiontransfer::ImageSet::setSubpixelFactor | ( | int | subpixFact | ) |
Sets the subpixel factor for this image set.
Definition at line 521 of file imageset.cpp.
void visiontransfer::ImageSet::setTimestamp | ( | int | seconds, |
int | microsec | ||
) |
Sets the time at which this image set has been captured.
seconds | The time stamp with a resolution of one second. |
microsec | The fractional seconds part of the time stamp with a resolution of 1 microsecond. |
Definition at line 513 of file imageset.cpp.
void visiontransfer::ImageSet::setWidth | ( | int | w | ) |
Sets a new width for both images.
Definition at line 485 of file imageset.cpp.
|
inline |
Converts one image of the set to an OpenCV image.
imageNumber | The number of the image that shall be converted (0 ... getNumberOfImages()-1). |
convertRgbToBgr | If 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.
void visiontransfer::ImageSet::writePgmFile | ( | int | imageNumber, |
const char * | fileName | ||
) | const |
Writes one image of the set to a PGM or PPM file.
imageNumber | The number of the image that shall be written. |
File | name of the PGM or PPM file that shall be created. |
Definition at line 581 of file imageset.cpp.