libvisiontransfer
4.1.2
|
Transforms a disparity map into a set of 3D points. More...
#include <visiontransfer/reconstruct3d.h>
Classes | |
class | Pimpl |
Public Member Functions | |
Reconstruct3D () | |
Constructs a new object for 3D reconstructing. More... | |
float * | createPointMap (const unsigned short *dispMap, int width, int height, int rowStride, const float *q, unsigned short minDisparity=1) |
Reconstructs the 3D location of each pixel in the given disparity map. More... | |
float * | createPointMap (const ImagePair &imagePair, unsigned short minDisparity=1) |
Reconstructs the 3D location of each pixel in the given disparity map. More... | |
void | writePlyFile (const char *file, const unsigned short *dispMap, const unsigned char *image, int width, int height, int dispRowStride, int imageRowStride, const float *q, double maxZ=std::numeric_limits< double >::max()) |
Projects the given disparity map to 3D points and exports the result to a PLY file. More... | |
void | writePlyFile (const char *file, const ImagePair &imagePair, double maxZ=std::numeric_limits< double >::max()) |
Projects the given disparity map to 3D points and exports the result to a PLY file. More... | |
Transforms a disparity map into a set of 3D points.
Use this class for reconstructing the 3D location for each valid point in a disparity map.
Definition at line 28 of file reconstruct3d.h.
Reconstruct3D::Reconstruct3D | ( | ) |
Constructs a new object for 3D reconstructing.
Definition at line 66 of file reconstruct3d.cpp.
float * Reconstruct3D::createPointMap | ( | const unsigned short * | dispMap, |
int | width, | ||
int | height, | ||
int | rowStride, | ||
const float * | q, | ||
unsigned short | minDisparity = 1 |
||
) |
Reconstructs the 3D location of each pixel in the given disparity map.
dispMap | Pointer to the data of the disparity map. The disparity map is assumed to have a 4-bit subpixel resolution. This means that each value needs to be divided by 16 to receive the true disparity. |
width | Width of the disparity map. |
height | Height of the disparity map. |
rowStride | Row stride (i.e. distance between two rows in bytes) of the disparity map. |
q | Disparity-to-depth mapping matrix of size 4x4. The matrix is stored in a row-wise alignment. Obtain this matrix from your camera calibration data. |
minDisparity | The minimum disparity, again with 4-bit subpixel resolution. Lower disparities will be clamped to this value before computing the 3D location. |
The output map will have a size of exactly 4*width*height float values. For each point the x, y and z coordinates are stored consecutively, plus one additional float (four bytes) as padding. Invalid disparities will be set to the given minimum disparity.
If the minimum disparity is set to 0, points with a disparity of 0 or an invalid disparity will receive a z coordinate of +inf.
The returned point map is valid until the next call of createPointMap() or writePlyFile().
Definition at line 74 of file reconstruct3d.cpp.
float * Reconstruct3D::createPointMap | ( | const ImagePair & | imagePair, |
unsigned short | minDisparity = 1 |
||
) |
Reconstructs the 3D location of each pixel in the given disparity map.
imagePair | Image pair containing the disparity map. |
minDisparity | The minimum disparity with 4-bit subpixel resolution. |
The second image in imagePair
is interpreted as the disparity map.
Please see createPointMap(const unsigned short*, int, int, int, const float*, unsigned short) for further details.
Definition at line 79 of file reconstruct3d.cpp.
void Reconstruct3D::writePlyFile | ( | const char * | file, |
const unsigned short * | dispMap, | ||
const unsigned char * | image, | ||
int | width, | ||
int | height, | ||
int | dispRowStride, | ||
int | imageRowStride, | ||
const float * | q, | ||
double | maxZ = std::numeric_limits<double>::max() |
||
) |
Projects the given disparity map to 3D points and exports the result to a PLY file.
file | The output file |
dispMap | Pointer to the data of the disparity map. The disparity map is assumed to have a 4-bit subpixel resolution. This means that each value needs to be divided by 16 to receive the true disparity. |
left | Rectified left input image in 8-bit gray scale format. |
width | Width of the disparity map and left image. |
height | Height of the disparity map and left image. |
dispRowStride | Row stride (i.e. distance between two rows in bytes) of the disparity map. |
imageRowStride | Row stride (i.e. distance between two rows in bytes) of the left image. |
q | Disparity-to-depth mapping matrix of size 4x4. The matrix is stored in a row-wise alignment. Obtain this matrix from your camera calibration data. |
maxZ | Maximum allowed z-coordinate. Points with a higher z-coordinate are not exported. |
The left image has to be provided for assigning a color to each point.
Definition at line 83 of file reconstruct3d.cpp.
void Reconstruct3D::writePlyFile | ( | const char * | file, |
const ImagePair & | imagePair, | ||
double | maxZ = std::numeric_limits<double>::max() |
||
) |
Projects the given disparity map to 3D points and exports the result to a PLY file.
imagePair | Image pair containing camera image and disparity map. |
maxZ | Maximum allowed z-coordinate. |
The first image in imagePair
is interpreted as camera image and the second image as disparity map.
Please see writePlyFile(const char*, const unsigned short*, const unsigned char*, int, int, int, int, const float*, double) for further details.
Definition at line 90 of file reconstruct3d.cpp.