libvisiontransfer  4.1.5
imagepair.h
1 /*******************************************************************************
2  * Copyright (c) 2017 Nerian Vision Technologies
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *******************************************************************************/
14 
15 #ifndef VISIONTRANSFER_IMAGEPAIR_H
16 #define VISIONTRANSFER_IMAGEPAIR_H
17 
18 #include <cassert>
19 #include <cstddef>
20 #include "visiontransfer/common.h"
21 
30 class VT_EXPORT ImagePair {
31 public:
35  enum ImageFormat {
38 
41  FORMAT_12_BIT
42  };
43 
47  ImagePair(): width(0), height(0), qMatrix(NULL), timeSec(0), timeMicrosec(0),
48  seqNum(0), minDisparity(0), maxDisparity(0) {
49  formats[0] = FORMAT_8_BIT;
50  formats[1] = FORMAT_8_BIT;
51  data[0] = NULL;
52  data[1] = NULL;
53  rowStride[0] = 0;
54  rowStride[1] = 1;
55  }
56 
60  void setWidth(int w) {width = w;}
61 
65  void setHeight(int h) {height = h;}
66 
74  void setRowStride(int imageNumber, int stride) {
75  assert(imageNumber >= 0 && imageNumber <=1);
76  rowStride[imageNumber] = stride;
77  }
78 
86  void setPixelFormat(int imageNumber, ImageFormat format) {
87  assert(imageNumber >= 0 && imageNumber <=1);
88  formats[imageNumber] = format;
89  }
90 
98  void setPixelData(int imageNumber, unsigned char* pixelData) {
99  assert(imageNumber >= 0 && imageNumber <=1);
100  data[imageNumber] = pixelData;
101  }
102 
109  void setQMatrix(const float* q) {
110  qMatrix = q;
111  }
112 
116  void setSequenceNumber(unsigned int num) {
117  seqNum = num;
118  }
119 
127  void setTimestamp(int seconds, int microsec) {
128  timeSec = seconds;
129  timeMicrosec = microsec;
130  }
131 
139  void setDisparityRange(int minimum, int maximum) {
140  minDisparity = minimum;
141  maxDisparity = maximum;
142  }
143 
147  int getWidth() const {return width;}
148 
152  int getHeight() const {return height;}
153 
160  int getRowStride(int imageNumber) const {
161  assert(imageNumber >= 0 && imageNumber <=1);
162  return rowStride[imageNumber];
163  }
164 
171  ImageFormat getPixelFormat(int imageNumber) const {
172  assert(imageNumber >= 0 && imageNumber <=1);
173  return formats[imageNumber];
174  }
175 
182  unsigned char* getPixelData(int imageNumber) const {
183  assert(imageNumber >= 0 && imageNumber <=1);
184  return data[imageNumber];
185  }
186 
190  const float* getQMatrix() const {
191  return qMatrix;
192  }
193 
197  unsigned int getSequenceNumber() const {return seqNum;}
198 
206  void getTimestamp(int& seconds, int& microsec) const {
207  seconds = timeSec;
208  microsec = timeMicrosec;
209  }
210 
219  void getDisparityRange(int& minimum, int& maximum) const {
220  minimum = minDisparity;
221  maximum = maxDisparity;
222  }
223 
230  void writePgmFile(int imageNumber, const char* fileName);
231 
232 private:
233  // No pimpl idiom here as almost everything is inlined.
234 
235  int width;
236  int height;
237  int rowStride[2];
238  ImageFormat formats[2];
239  unsigned char* data[2];
240  const float* qMatrix;
241  int timeSec;
242  int timeMicrosec;
243  unsigned int seqNum;
244  int minDisparity;
245  int maxDisparity;
246 };
247 
248 #endif
249 
void setTimestamp(int seconds, int microsec)
Sets the time at which this image pair has been captured.
Definition: imagepair.h:127
void setHeight(int h)
Sets a new width for both images.
Definition: imagepair.h:65
void setSequenceNumber(unsigned int num)
Sets the sequence number for this image pair.
Definition: imagepair.h:116
void setPixelFormat(int imageNumber, ImageFormat format)
Sets the pixel format for the given image.
Definition: imagepair.h:86
unsigned char * getPixelData(int imageNumber) const
Returns the pixel data for the given image.
Definition: imagepair.h:182
const float * getQMatrix() const
Returns a pointer to the disparity-to-depth mapping matrix q.
Definition: imagepair.h:190
int getWidth() const
Returns the width of each image.
Definition: imagepair.h:147
void setDisparityRange(int minimum, int maximum)
Sets the value range for the disparity map contained in this image pair.
Definition: imagepair.h:139
void setWidth(int w)
Sets a new width for both images.
Definition: imagepair.h:60
void setQMatrix(const float *q)
Sets the pointer to the disparity-to-depth mapping matrix q.
Definition: imagepair.h:109
void setRowStride(int imageNumber, int stride)
Sets a new row stride for the pixel data of one image.
Definition: imagepair.h:74
ImagePair()
Default constructor creating an image pair with no pixel data.
Definition: imagepair.h:47
void getTimestamp(int &seconds, int &microsec) const
Returns the time at which this image pair has been captured.
Definition: imagepair.h:206
void setPixelData(int imageNumber, unsigned char *pixelData)
Sets the pixel data for the given image.
Definition: imagepair.h:98
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 c...
Definition: imagepair.h:219
A set of two images, which are usually the left camera image and the disparity map.
Definition: imagepair.h:30
ImageFormat getPixelFormat(int imageNumber) const
Returns the pixel format for the given image.
Definition: imagepair.h:171
8-bit greyscale format
Definition: imagepair.h:37
int getHeight() const
Returns the height of each image.
Definition: imagepair.h:152
unsigned int getSequenceNumber() const
Returns the sequence number for this image pair.
Definition: imagepair.h:197
int getRowStride(int imageNumber) const
Returns the row stride for the pixel data of one image.
Definition: imagepair.h:160
ImageFormat
Image formats that can be transferred.
Definition: imagepair.h:35
Nerian Vision Technologies