15 #ifndef VISIONTRANSFER_IMAGESET_H 16 #define VISIONTRANSFER_IMAGESET_H 20 #include "visiontransfer/common.h" 40 static const int MAX_SUPPORTED_IMAGES = 3;
60 FORMAT_8_BIT = FORMAT_8_BIT_MONO,
61 FORMAT_12_BIT = FORMAT_12_BIT_MONO
105 assert(imageNumber >= 0 && imageNumber < getNumberOfImages());
106 rowStride[imageNumber] = stride;
117 assert(imageNumber >= 0 && imageNumber < getNumberOfImages());
118 formats[imageNumber] = format;
121 #ifndef DOXYGEN_SHOULD_SKIP_THIS 122 DEPRECATED(
"Use setPixelFormat(int, ImageFormat) instead")
void setPixelFormat(
int imageNumber,
ImageFormat_Deprecated format) {
123 setPixelFormat(imageNumber, static_cast<ImageFormat>(format));
135 assert(imageNumber >= 0 && imageNumber < getNumberOfImages());
136 data[imageNumber] = pixelData;
165 timeMicrosec = microsec;
176 minDisparity = minimum;
177 maxDisparity = maximum;
184 subpixelFactor = subpixFact;
187 #ifndef DOXYGEN_SHOULD_SKIP_THIS 195 DEPRECATED(
"Only compatible with two-image sets: use setNumberOfImages() and setIndexOf() instead")
196 void setImageDisparityPair(
bool dispPair);
219 assert(imageNumber >= 0 && imageNumber < getNumberOfImages());
220 return rowStride[imageNumber];
232 int idx = getIndexOf(what,
true);
233 return getRowStride(idx);
246 assert(imageNumber >= 0 && imageNumber < getNumberOfImages());
247 return formats[imageNumber];
259 int idx = getIndexOf(what,
true);
260 return getPixelFormat(idx);
273 assert(imageNumber >= 0 && imageNumber < getNumberOfImages());
274 return data[imageNumber];
286 int idx = getIndexOf(what,
true);
287 return getPixelData(idx);
311 microsec = timeMicrosec;
323 minimum = minDisparity;
324 maximum = maxDisparity;
331 return subpixelFactor;
340 void writePgmFile(
int imageNumber,
const char* fileName)
const;
342 #ifndef DOXYGEN_SHOULD_SKIP_THIS 355 DEPRECATED(
"Only compatible with two-image sets: use hasImageType(ImageSet::IMAGE_DISPARITY) instead")
356 bool isImageDisparityPair()
const {
357 return (getNumberOfImages()==2) && hasImageType(IMAGE_DISPARITY);
373 assert(imageNumber >= 0 && imageNumber < getNumberOfImages());
374 return getBytesPerPixel(formats[imageNumber]);
384 assert(imageNumber >= 0 && imageNumber < getNumberOfImages());
385 return getBitsPerPixel(formats[imageNumber]);
388 int getBitsPerPixel(
ImageType what)
const {
389 int idx = getIndexOf(what,
true);
390 return getBitsPerPixel(idx);
405 return numberOfImages;
412 assert(number >= 1 && number <= MAX_SUPPORTED_IMAGES);
413 numberOfImages = number;
419 ImageType getImageType(
int imageNumber)
const;
429 int getIndexOf(
ImageType what,
bool throwIfNotFound=
false)
const;
435 return getIndexOf(what) >= 0;
446 void setIndexOf(
ImageType what,
int idx);
449 #ifdef CV_MAJOR_VERSION 464 inline void toOpenCVImage(
int imageNumber, cv::Mat& dest,
bool convertRgbToBgr =
true);
473 exposureTime = timeMicrosec;
494 lastSyncPulseSec = seconds;
495 lastSyncPulseMicrosec = microsec;
506 seconds = lastSyncPulseSec;
507 microsec = lastSyncPulseMicrosec;
514 int rowStride[MAX_SUPPORTED_IMAGES];
516 unsigned char* data[MAX_SUPPORTED_IMAGES];
517 const float* qMatrix;
524 int* referenceCounter;
529 int indexDisparityImage;
532 int lastSyncPulseSec;
533 int lastSyncPulseMicrosec;
536 void decrementReference();
539 #ifndef DOXYGEN_SHOULD_SKIP_THIS 541 class DEPRECATED("Use ImageSet instead.") ImagePair:
public ImageSet {
547 #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.