15 #ifndef VISIONTRANSFER_IMAGESET_H 16 #define VISIONTRANSFER_IMAGESET_H 20 #include "visiontransfer/common.h" 40 static const int MAX_SUPPORTED_IMAGES = 4;
60 FORMAT_8_BIT = FORMAT_8_BIT_MONO,
61 FORMAT_12_BIT = FORMAT_12_BIT_MONO
108 assert(imageNumber >= 0 && imageNumber < getNumberOfImages());
109 rowStride[imageNumber] = stride;
120 assert(imageNumber >= 0 && imageNumber < getNumberOfImages());
121 formats[imageNumber] = format;
124 #ifndef DOXYGEN_SHOULD_SKIP_THIS 125 DEPRECATED(
"Use setPixelFormat(int, ImageFormat) instead")
void setPixelFormat(
int imageNumber,
ImageFormat_Deprecated format) {
126 setPixelFormat(imageNumber, static_cast<ImageFormat>(format));
138 assert(imageNumber >= 0 && imageNumber < getNumberOfImages());
139 data[imageNumber] = pixelData;
168 timeMicrosec = microsec;
179 minDisparity = minimum;
180 maxDisparity = maximum;
187 subpixelFactor = subpixFact;
190 #ifndef DOXYGEN_SHOULD_SKIP_THIS 198 DEPRECATED(
"Only compatible with two-image sets: use setNumberOfImages() and setIndexOf() instead")
199 void setImageDisparityPair(
bool dispPair);
222 assert(imageNumber >= 0 && imageNumber < getNumberOfImages());
223 return rowStride[imageNumber];
235 int idx = getIndexOf(what,
true);
236 return getRowStride(idx);
249 assert(imageNumber >= 0 && imageNumber < getNumberOfImages());
250 return formats[imageNumber];
262 int idx = getIndexOf(what,
true);
263 return getPixelFormat(idx);
276 assert(imageNumber >= 0 && imageNumber < getNumberOfImages());
277 return data[imageNumber];
289 int idx = getIndexOf(what,
true);
290 return getPixelData(idx);
314 microsec = timeMicrosec;
326 minimum = minDisparity;
327 maximum = maxDisparity;
334 return subpixelFactor;
343 void writePgmFile(
int imageNumber,
const char* fileName)
const;
345 #ifndef DOXYGEN_SHOULD_SKIP_THIS 358 DEPRECATED(
"Only compatible with two-image sets: use hasImageType(ImageSet::IMAGE_DISPARITY) instead")
359 bool isImageDisparityPair()
const {
360 return (getNumberOfImages()==2) && hasImageType(IMAGE_DISPARITY);
376 assert(imageNumber >= 0 && imageNumber < getNumberOfImages());
377 return getBytesPerPixel(formats[imageNumber]);
387 assert(imageNumber >= 0 && imageNumber < getNumberOfImages());
388 return getBitsPerPixel(formats[imageNumber]);
391 int getBitsPerPixel(
ImageType what)
const {
392 int idx = getIndexOf(what,
true);
393 return getBitsPerPixel(idx);
408 return numberOfImages;
415 assert(number >= 1 && number <= MAX_SUPPORTED_IMAGES);
416 numberOfImages = number;
422 ImageType getImageType(
int imageNumber)
const;
432 int getIndexOf(
ImageType what,
bool throwIfNotFound=
false)
const;
438 return getIndexOf(what) >= 0;
449 void setIndexOf(
ImageType what,
int idx);
452 #ifdef CV_MAJOR_VERSION 467 inline void toOpenCVImage(
int imageNumber, cv::Mat& dest,
bool convertRgbToBgr =
true);
476 exposureTime = timeMicrosec;
497 lastSyncPulseSec = seconds;
498 lastSyncPulseMicrosec = microsec;
509 seconds = lastSyncPulseSec;
510 microsec = lastSyncPulseMicrosec;
517 int rowStride[MAX_SUPPORTED_IMAGES];
519 unsigned char* data[MAX_SUPPORTED_IMAGES];
520 const float* qMatrix;
527 int* referenceCounter;
532 int indexDisparityImage;
536 int lastSyncPulseSec;
537 int lastSyncPulseMicrosec;
540 void decrementReference();
543 #ifndef DOXYGEN_SHOULD_SKIP_THIS 545 class DEPRECATED("Use ImageSet instead.") ImagePair:
public ImageSet {
551 #include "visiontransfer/imageset-opencv.h"
void setNumberOfImages(int number)
Sets the number of valid images in this set.
int getRowStride(int imageNumber) const
Returns the row stride for the pixel data of one image.
void setTimestamp(int seconds, int microsec)
Sets the time at which this image set has been captured.
void setPixelData(int imageNumber, unsigned char *pixelData)
Sets the pixel data for the given image.
void getTimestamp(int &seconds, int µsec) const
Returns the time at which this image set has been captured.
const float * getQMatrix() const
Returns a pointer to the disparity-to-depth mapping matrix q.
void setWidth(int w)
Sets a new width for both images.
int getBitsPerPixel(int imageNumber) const
Returns the number of bits that are required to store one image pixel.
int getNumberOfImages() const
Returns the number of images in this set.
void setExposureTime(int timeMicrosec)
Sets the exposure time that was used for capturing the image set.
int getExposureTime() const
Gets the exposure time in microseconds that was used for capturing the image set. ...
unsigned int getSequenceNumber() const
Returns the sequence number for this image set.
void setSequenceNumber(unsigned int num)
Sets the sequence number for this image set.
int getHeight() const
Returns the height of each image.
void setHeight(int h)
Sets a new width for both images.
unsigned char * getPixelData(ImageType what) const
Returns the pixel data for the given image.
int getBytesPerPixel(int imageNumber) const
Returns the number of bytes that are required to store one image pixel.
int getSubpixelFactor() const
Gets the subpixel factor for this image set.
void setPixelFormat(int imageNumber, ImageFormat format)
Sets the pixel format for the given image.
void setRowStride(int imageNumber, int stride)
Sets a new row stride for the pixel data of one image.
void setLastSyncPulse(int seconds, int microsec)
Sets the timestamp of the last received sync pulse.
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 con...
ImageType
Supported image types.
ImageFormat
Image formats that can be transferred.
unsigned char * getPixelData(int imageNumber) const
Returns the pixel data for the given image.
bool hasImageType(ImageType what) const
Returns whether a left camera image is included in the enabled data.
A set of one to three images, but usually two (the left camera image and the disparity map)...
ImageFormat getPixelFormat(int imageNumber) const
Returns the pixel format for the given image.
void getLastSyncPulse(int &seconds, int µsec) const
Gets the timestamp of the last received sync pulse.
int getRowStride(ImageType what) const
Returns the row stride for the pixel data of one image.
ImageFormat getPixelFormat(ImageType what) const
Returns the pixel format for the given image.
void setDisparityRange(int minimum, int maximum)
Sets the value range for the disparity map contained in this image set.
int getWidth() const
Returns the width of each image.
void setSubpixelFactor(int subpixFact)
Sets the subpixel factor for this image set.
void setQMatrix(const float *q)
Sets the pointer to the disparity-to-depth mapping matrix q.