libvisiontransfer  6.0.0
Classes | Public Member Functions | List of all members
Reconstruct3D Class Reference

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 projectSinglePoint (int imageX, int imageY, unsigned short disparity, const float *q, float &pointX, float &pointY, float &pointZ)
 Reconstructs the 3D location of one individual point. More...
 
void writePlyFile (const char *file, const unsigned short *dispMap, const unsigned char *image, int width, int height, bool isRgb, int dispRowStride, int imageRowStride, const float *q, double maxZ=std::numeric_limits< double >::max(), bool binary=false)
 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(), bool binary=false)
 Projects the given disparity map to 3D points and exports the result to a PLY file. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

Reconstruct3D::Reconstruct3D ( )

Constructs a new object for 3D reconstructing.

Definition at line 70 of file reconstruct3d.cpp.

Member Function Documentation

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.

Parameters
dispMapPointer 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.
widthWidth of the disparity map.
heightHeight of the disparity map.
rowStrideRow stride (i.e. distance between two rows in bytes) of the disparity map.
qDisparity-to-depth mapping matrix of size 4x4. The matrix is stored in a row-wise alignment. Obtain this matrix from your camera calibration data.
minDisparityThe 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 78 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.

Parameters
imagePairImage pair containing the disparity map.
minDisparityThe 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 83 of file reconstruct3d.cpp.

void Reconstruct3D::projectSinglePoint ( int  imageX,
int  imageY,
unsigned short  disparity,
const float *  q,
float &  pointX,
float &  pointY,
float &  pointZ 
)

Reconstructs the 3D location of one individual point.

Parameters
imageXX component of the image location.
imageYY component of the image location.
disparityValue of the disparity map at the image location. It is assumed that the lower 4 bits are the fractional component. This means that each value needs to be divided by 16 to receive the true disparity.
qDisparity-to-depth mapping matrix of size 4x4. The matrix is stored in a row-wise alignment. Obtain this matrix from your camera calibration data.
pointXDestination variable for the 3D point X component.
pointYDestination variable for the 3D point Y component.
pointZDestination variable for the 3D point Z component.

This method projects a single point from a disparity map to a 3D location. If the 3D coordinates of multiple points are of interest, createPointMap() should be used for best performance.

Definition at line 87 of file reconstruct3d.cpp.

void Reconstruct3D::writePlyFile ( const char *  file,
const unsigned short *  dispMap,
const unsigned char *  image,
int  width,
int  height,
bool  isRgb,
int  dispRowStride,
int  imageRowStride,
const float *  q,
double  maxZ = std::numeric_limits<double>::max(),
bool  binary = false 
)

Projects the given disparity map to 3D points and exports the result to a PLY file.

Parameters
fileThe output file
dispMapPointer 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.
leftRectified left input image in 8-bit gray scale format.
widthWidth of the disparity map and left image.
heightHeight of the disparity map and left image.
isRgbFor color images this parameter should be set to true, for mono images it should be false.
dispRowStrideRow stride (i.e. distance between two rows in bytes) of the disparity map.
imageRowStrideRow stride (i.e. distance between two rows in bytes) of the left image.
qDisparity-to-depth mapping matrix of size 4x4. The matrix is stored in a row-wise alignment. Obtain this matrix from your camera calibration data.
maxZMaximum allowed z-coordinate. Points with a higher z-coordinate are not exported.
binarySpecifies whether the ASCII or binary PLY-format should be used.

The left image has to be provided for assigning a color to each point.

Definition at line 92 of file reconstruct3d.cpp.

void Reconstruct3D::writePlyFile ( const char *  file,
const ImagePair imagePair,
double  maxZ = std::numeric_limits<double>::max(),
bool  binary = false 
)

Projects the given disparity map to 3D points and exports the result to a PLY file.

Parameters
imagePairImage pair containing camera image and disparity map.
maxZMaximum allowed z-coordinate.
binarySpecifies whether the ASCII or binary PLY-format should be used.

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, bool, int, int, const float*, double) for further details.

Definition at line 99 of file reconstruct3d.cpp.


The documentation for this class was generated from the following files:
Nerian Vision Technologies