DAVID4 SDK  1.8.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
david::IStructuredLightScanner Class Referenceabstract

Interface class for 'Structured Light Scanning'. More...

#include <IStructuredLightScanner.h>

Inheritance diagram for david::IStructuredLightScanner:
david::StructuredLightScannerD4Lib david::StructuredLightScannerJsonRpc

Public Member Functions

virtual ~IStructuredLightScanner ()
 Destructor.
 
Internal camera and projector interface
virtual void SetScreenID (int screenID)=0
 Set the new screen ID. More...
 
virtual std::vector< std::string > GetAvailableCameraNames ()=0
 Returns a list of available cameras. More...
 
virtual void SelectCamera (const std::string &cameraName, const ImageFormat &imageFormat=ImageFormat())=0
 Select a new camera. More...
 
virtual bool CheckCamera ()=0
 Check state of camera. More...
 
virtual void SetCameraProperty (const std::string &propertyName, double value, enum CamPropsUsage camPropsUsage=CamPropsForAll)=0
 Set the camera property 'propertyName'. More...
 
virtual double GetCameraProperty (const std::string &propertyName, enum CamPropsUsage camPropsUsage=CamPropsForScanning)=0
 Get the camera property 'propertyName'. More...
 
virtual std::vector< std::string > GetCameraPropertyNames (bool onlyAvailable)=0
 Get a list of camera property names. More...
 
virtual void GetLiveImage (std::vector< uint8_t > &pixelValues, int &width, int &height)=0
 Get the current grayscale live image from the camera. More...
 
External camera and projector interface
virtual void SelectImageSequence (const std::string &directory)=0
 Selects a sequence of image files as "virtual camera". More...
 
virtual int GetPatternCount ()=0
 Get the current number of pattern for the complete sequence. More...
 
virtual void GetPatternImage (uint8_t *data, int width, int height, PatternPixelFormat pixelFormat, int patternIndex)=0
 Get the pattern image with the zero based index 'patternIndex'. More...
 
virtual void SetCapturedImage (const uint8_t *data, int width, int height, CapturedPixelFormat pixelFormat, int patternIndex)=0
 Set the captured image for given pattern with zero based index 'patternIndex'. More...
 
virtual void SetTextureImage (const uint8_t *data, int width, int height, PixelFormat pixelFormat)=0
 Set the texture image analog to SetCapturedImage. More...
 
Calibration
virtual void ImportCalibration (const std::string &camCalibFilename, const std::string &projectorCalibFilename)=0
 Import camera and projector calibration from XML files. More...
 
virtual void ExportCalibration (const std::string &camCalibFilename, const std::string &projectorCalibFilename)=0
 Export camera and projector calibration to XML files. More...
 
virtual void ChangeCameraCalibrationResolution (int newWidth, int newHeight)=0
 Change resolution of image format used camera calibration. More...
 
virtual std::vector< CalibPointCalibrate (double scale)=0
 Trigger automatic calibration of the Structured Light Scanner. More...
 
Scanning
virtual void SetCodedLightPhaseShiftMode (const CodedLightPhaseShiftParams &params)=0
 Select scan mode Coded Light + Phase Shift (standard DAVID4 mode) and sets the parameters. More...
 
virtual CodedLightPhaseShiftParams GetCodedLightPhaseShiftParams ()=0
 Get current SLS params for Coded Light and Phase Shift. More...
 
virtual void SetResultFiltering (const ResultFilteringParams &params)=0
 Set the result filtering parameters for SL scans. More...
 
virtual ResultFilteringParams GetResultFiltering ()=0
 Get the result filtering parameters for SL scans. More...
 
virtual int Scan (bool grabTexture=false, bool setAsBackground=false)=0
 Trigger a Structured Light Scan. More...
 
virtual void GrabTexture ()=0
 Grab a new texture.
 
virtual void AutoWhiteBalance ()=0
 Execute an auto white balancing procedure.
 
virtual int AddScanToShapeFusion ()=0
 Add the current scan to 'Shape Fusion' module. More...
 
virtual void ExportMesh (const std::string &filename)=0
 Export the current scan as a triangular mesh. More...
 
Background removal
virtual void ExportBackgroundDepthmap (const std::string &filename)=0
 Export the current background as a depth map file (.PFM). More...
 
virtual void ImportBackgroundDepthmap (const std::string &filename)=0
 Import background from a depth map file (.PFM). More...
 
virtual void GetBackgroundDepthmap (std::vector< float > &depthValues, int &width, int &height)=0
 Gets the currently used background scan as depth map. More...
 
virtual void SetBackgroundDepthmap (const std::vector< float > &depthValues, int width, int height)=0
 Sets the background scan, giving a depth map. More...
 
virtual void SetBackgroundPlanes (const std::vector< Plane > &planes)=0
 Sets the "background scan" from a given list of planes. More...
 

Static Public Member Functions

Calibration (static functions)
static void GetCalibrationError (double &maxDelta, double &rmsError, const std::vector< CalibPoint > &calibPoints)
 Helper function for computing the calibration error given an array of calibration correspondences. More...
 

Detailed Description

Interface class for 'Structured Light Scanning'.

Example:

/// Shows usage of StructuredLightScanner class.
#include "davidSDK/david.h"
#include <iostream>
namespace examples {
{
try
{
// Connect to DAVID server.
// david::Client::Disconnect is automatically called in destructor of david::Client.
david.Connect();
// Select screen.
david.sls().SetScreenID(2);
// I) Select camera directly:
// david.sls().SelectCamera("DAVID-CAM-3-M (8F6DEE1E)");
// II) Select camera based on common name: Select any DAVID cam.
std::vector<std::string> cameraNames = david.sls().GetAvailableCameraNames();
for (size_t i=0; i < cameraNames.size(); ++i)
{
if (cameraNames[i].find("DAVID-CAM") != std::string::npos)
{
david.sls().SelectCamera(cameraNames[i]);
break;
}
}
// Get current exposure for scanning.
std::cout << "Exposure: " << david.sls().GetCameraProperty("exposure") << std::endl;
// Tells DAVID server to make a new scan and save it under 'filename'.
int num = david.sls().Scan();
std::cout << "New scan consists of " << num << " 3D points\n";
david.sls().ExportMesh("scan.obj");
}
catch (david::Exception& e)
{
}
}
} // namespace examples

Definition at line 172 of file IStructuredLightScanner.h.

Member Function Documentation

virtual int david::IStructuredLightScanner::AddScanToShapeFusion ( )
pure virtual

Add the current scan to 'Shape Fusion' module.

Returns
ID of the mesh.
Exceptions
david::Error_MissingObject(david::FunctionException) No scan data at hand.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

Examples:
SimpleMeshComparison.cpp, SimpleTurntable.cpp, and TimedScans.cpp.
virtual std::vector<CalibPoint> david::IStructuredLightScanner::Calibrate ( double  scale)
pure virtual

Trigger automatic calibration of the Structured Light Scanner.

The function returns when calibration is finished or an error occurred.

Parameters
[in]scaleScale of the calibration patterns. Typically in mm.
Returns
If calibration is successful: Array of correspondences used for calibration. Empty array otherwise.
Exceptions
david::Error_CameraCalibration(david::FunctionException) Camera calibration failed.
david::Error_ProjectorCalibration(david::FunctionException) Projector calibration failed.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual void david::IStructuredLightScanner::ChangeCameraCalibrationResolution ( int  newWidth,
int  newHeight 
)
pure virtual

Change resolution of image format used camera calibration.

Warning
The aspect ratio is not allowed to change.
Parameters
[in]newWidthNew camera image width.
[in]newHeightNew camera image height.
Exceptions
david::Error_NotCalibrated(david::FunctionException) Camera is not calibrated.
david::Error_InvalidFormat(david::FunctionException) Requested image resolution not supported.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual bool david::IStructuredLightScanner::CheckCamera ( )
pure virtual

Check state of camera.

Returns
False, if camera is not working correctly or camera is not connected.
True, if camera is connected and is working correctly.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual void david::IStructuredLightScanner::ExportBackgroundDepthmap ( const std::string &  filename)
pure virtual

Export the current background as a depth map file (.PFM).

Parameters
[in]filenameFilename of the depth map to be exported.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual void david::IStructuredLightScanner::ExportCalibration ( const std::string &  camCalibFilename,
const std::string &  projectorCalibFilename 
)
pure virtual

Export camera and projector calibration to XML files.

Parameters
[in]camCalibFilenameFilename of the camera calibration to be exported to.
[in]projectorCalibFilenameFilename of the projector calibration to be exported to.
Exceptions
david::Error_NotCalibrated(david::FunctionException) Scanner is not calibrated.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual void david::IStructuredLightScanner::ExportMesh ( const std::string &  filename)
pure virtual

Export the current scan as a triangular mesh.

See documentation of DAVID software for supported file formats.

Warning
File paths like "c:\\meshes\\myobject.obj" are interpreted as files located on the server. For files located on the client you have to use a shared network path like "\\\\mycomputer\\meshes\\myobject.obj".
Parameters
[in]filenameFilename of the mesh to be exported.
Exceptions
david::Error_NoAccess(david::FunctionException) No access to path.
david::Error_InvalidPath(david::FunctionException) Export path invalid.
david::Error_DirectoryNotFound(david::FunctionException) Export target directory does not exist.
david::Error_MissingFilename(david::FunctionException) Export path misses file name.
david::Error_InvalidMeshId(david::FunctionException) Specified meshID does not exist.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

Examples:
SimpleStructuredLightScanner.cpp, and TimedScans.cpp.
virtual std::vector<std::string> david::IStructuredLightScanner::GetAvailableCameraNames ( )
pure virtual

Returns a list of available cameras.

Returns
The list of names.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

Examples:
SimpleMeshComparison.cpp, and SimpleStructuredLightScanner.cpp.
virtual void david::IStructuredLightScanner::GetBackgroundDepthmap ( std::vector< float > &  depthValues,
int &  width,
int &  height 
)
pure virtual

Gets the currently used background scan as depth map.

Parameters
[out]depthValuesThe depth values, row by row, from top to bottom, each row left to right.
[out]widthNumber of columns
[out]heightNumber of rows

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

static void david::IStructuredLightScanner::GetCalibrationError ( double &  maxDelta,
double &  rmsError,
const std::vector< CalibPoint > &  calibPoints 
)
static

Helper function for computing the calibration error given an array of calibration correspondences.

Parameters
[out]maxDeltaMaximum Euclidean distance [pixel] between any corresponding 'measuredPos2d' and 'projectedPos2d'.
[out]rmsErrorTotal root mean square error.
[in]calibPointsArray of calibration points. See david::CalibPoint.
virtual double david::IStructuredLightScanner::GetCameraProperty ( const std::string &  propertyName,
enum CamPropsUsage  camPropsUsage = CamPropsForScanning 
)
pure virtual

Get the camera property 'propertyName'.

Parameters
[in]propertyNameName of property.
[in]camPropsUsageFor which algorithm should the camera property be queried? See david::CamPropsSelect. CamPropsForAll is not allowed here.
Returns
Value of the camera property.
Exceptions
david::Error_DeviceNotAvailable(david::FunctionException) Selected camera is not available.
david::Error_InvalidArgument(david::FunctionException) Invalid property or property is not available.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

Examples:
SimpleStructuredLightScanner.cpp.
virtual std::vector<std::string> david::IStructuredLightScanner::GetCameraPropertyNames ( bool  onlyAvailable)
pure virtual

Get a list of camera property names.

Parameters
[in]onlyAvailableList only available camera properties?
Returns
Array of camera property names.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual CodedLightPhaseShiftParams david::IStructuredLightScanner::GetCodedLightPhaseShiftParams ( )
pure virtual

Get current SLS params for Coded Light and Phase Shift.

Returns
Parameters for this structured light mode. See david::CodedLightPhaseShiftParams.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual void david::IStructuredLightScanner::GetLiveImage ( std::vector< uint8_t > &  pixelValues,
int &  width,
int &  height 
)
pure virtual

Get the current grayscale live image from the camera.

Parameters
[out]pixelValues8bit gray scale pixel values are writting into this buffer.
[out]widthWidth of the image.
[out]heightHeight of the image.
Exceptions
david::Error_NoLiveImage(david::FunctionException) Live image is not available.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual int david::IStructuredLightScanner::GetPatternCount ( )
pure virtual

Get the current number of pattern for the complete sequence.

Returns
Number of pattern to be projected.

Implemented in david::StructuredLightScannerJsonRpc, and david::StructuredLightScannerD4Lib.

virtual void david::IStructuredLightScanner::GetPatternImage ( uint8_t *  data,
int  width,
int  height,
PatternPixelFormat  pixelFormat,
int  patternIndex 
)
pure virtual

Get the pattern image with the zero based index 'patternIndex'.

Parameters
[out]dataPixel values are written to this buffer.
  • PPF_Y800: Size has to be width*height bytes.
  • PPF_RGB24: Size has to be width*height*3 bytes.
[in]widthRequested width of pattern image.
[in]heightRequested height of pattern image.
[in]pixelFormatSupported pixel formats for pattern images.
[in]patternIndexZero based index of pattern image. See also GetPatternCount.

Implemented in david::StructuredLightScannerJsonRpc, and david::StructuredLightScannerD4Lib.

virtual ResultFilteringParams david::IStructuredLightScanner::GetResultFiltering ( )
pure virtual

Get the result filtering parameters for SL scans.

Returns
Current parameters for result filtering.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual void david::IStructuredLightScanner::ImportBackgroundDepthmap ( const std::string &  filename)
pure virtual

Import background from a depth map file (.PFM).

Parameters
[in]filenameFilename of the depth map to be imported.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual void david::IStructuredLightScanner::ImportCalibration ( const std::string &  camCalibFilename,
const std::string &  projectorCalibFilename 
)
pure virtual

Import camera and projector calibration from XML files.

Parameters
[in]camCalibFilenameFilename of the camera calibration to be imported from.
[in]projectorCalibFilenameFilename of the projector calibration to be imported from.
Exceptions
david::Error_CameraCalibration(david::FunctionException) Could not read camera calibration file.
david::Error_ProjectorCalibration(david::FunctionException) Could not read projector calibration file.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual int david::IStructuredLightScanner::Scan ( bool  grabTexture = false,
bool  setAsBackground = false 
)
pure virtual

Trigger a Structured Light Scan.

The function computes a 3D scan from a sequence of captured pattern images. The captured images can be provided in two ways:

  1. Camera and projector are selected (SelectCamera and SetScreenID): Selected camera and projector are used to capture a new sequence.
  2. Captured images have been provided via SelectImageSequence or SetCapturedImage + SetTextureImage.

The function returns when scanning is finished or an error occurred.

Parameters
[in]grabTextureAlso grab a texture with the scan (default: false)
[in]setAsBackgroundDefine this scan as background (for Background Removal in ResultFiltering) (default: false)
Returns
Number of triangulated 3D points.
Exceptions
david::Error_NotCalibrated(david::FunctionException) Cannot scan because scanner is not calibrated.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

Examples:
SimpleMeshComparison.cpp, SimpleStructuredLightScanner.cpp, SimpleTurntable.cpp, and TimedScans.cpp.
virtual void david::IStructuredLightScanner::SelectCamera ( const std::string &  cameraName,
const ImageFormat imageFormat = ImageFormat() 
)
pure virtual

Select a new camera.

Example:

SelectCamera("DAVID-CAM-3-M (8F6DEE1E)");
Parameters
[in]cameraNameName of the camera.
[in]imageFormatFormat of the camera image.
Exceptions
david::Error_DeviceNotAvailable(david::FunctionException) Selected camera is not available.
david::Error_FormatNotAvailable(david::FunctionException) Selected camera image format is invalid.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

Examples:
SimpleMeshComparison.cpp, and SimpleStructuredLightScanner.cpp.
virtual void david::IStructuredLightScanner::SelectImageSequence ( const std::string &  directory)
pure virtual

Selects a sequence of image files as "virtual camera".

All images must be located in the same directory. The image file names are chosen automatically:

Image for camera calibration File name must contain "cam_calib"
Pattern images File names must contain "image" and be sorted alphabetically.
Texture image File name must contain "texture"
Parameters
[in]directoryPath to the image files.
Exceptions
david::Error_InvalidPath(david::FunctionException) Path invalid.
david::Error_DirectoryNotFound(david::FunctionException) Directory does not exist.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual void david::IStructuredLightScanner::SetBackgroundDepthmap ( const std::vector< float > &  depthValues,
int  width,
int  height 
)
pure virtual

Sets the background scan, giving a depth map.

The resolution should be identical to the camera resolution.

Parameters
[in]depthValuesThe depth values, row by row, from top to bottom, each row left to right.
[in]widthNumber of columns
[in]heightNumber of rows

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual void david::IStructuredLightScanner::SetBackgroundPlanes ( const std::vector< Plane > &  planes)
pure virtual

Sets the "background scan" from a given list of planes.

Camera must be calibrated first!

Parameters
[in]planesThe list of planes that define the background.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual void david::IStructuredLightScanner::SetCameraProperty ( const std::string &  propertyName,
double  value,
enum CamPropsUsage  camPropsUsage = CamPropsForAll 
)
pure virtual

Set the camera property 'propertyName'.

Here are some important property names:

  • exposure (should be 1/60 s, 1/30 s, or 1/15 s for most cases)
  • gain (should be as low as possible)
  • brightness
  • sharpness
  • gamma
  • ....
Note
Not all cameras support all properties. See also GetCameraPropertyNames.
Parameters
[in]propertyNameName of property.
[in]valueNew value of the property.
[in]camPropsUsageFor which algorithm should the camera property be set? See david::CamPropsSelect.
Exceptions
david::Error_DeviceNotAvailable(david::FunctionException) Selected camera is not available.
david::Error_InvalidArgument(david::FunctionException) Invalid property or property is not available.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual void david::IStructuredLightScanner::SetCapturedImage ( const uint8_t *  data,
int  width,
int  height,
CapturedPixelFormat  pixelFormat,
int  patternIndex 
)
pure virtual

Set the captured image for given pattern with zero based index 'patternIndex'.

Parameters
[in]dataValid pointer to buffer with pixel values.
  • CPF_Y800: Size of 'data' has to be width*height.
[in]widthWidth of captured image.
[in]heightHeight of captured image.
[in]pixelFormatPixel format of captured image.
[in]patternIndexZero based index of pattern image. See also GetPatternCount.

Implemented in david::StructuredLightScannerJsonRpc, and david::StructuredLightScannerD4Lib.

virtual void david::IStructuredLightScanner::SetCodedLightPhaseShiftMode ( const CodedLightPhaseShiftParams params)
pure virtual

Select scan mode Coded Light + Phase Shift (standard DAVID4 mode) and sets the parameters.

Missing parameters will remain unchanged.

Parameters
[in]paramsParameters for this structured light mode.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual void david::IStructuredLightScanner::SetResultFiltering ( const ResultFilteringParams params)
pure virtual

Set the result filtering parameters for SL scans.

Parameters
[in]paramsParameters for result filtering.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

virtual void david::IStructuredLightScanner::SetScreenID ( int  screenID)
pure virtual

Set the new screen ID.

The value 0 switches the projection off.

Parameters
[in]screenIDID of the screen used for displaying structured light patterns, or 0 for OFF.

Implemented in david::StructuredLightScannerD4Lib, and david::StructuredLightScannerJsonRpc.

Examples:
SimpleMeshComparison.cpp, and SimpleStructuredLightScanner.cpp.
virtual void david::IStructuredLightScanner::SetTextureImage ( const uint8_t *  data,
int  width,
int  height,
PixelFormat  pixelFormat 
)
pure virtual

Set the texture image analog to SetCapturedImage.

Parameters
[in]dataValid pointer to buffer with pixel values. Size of 'data' has to be equal to GetImageSize(width, height, pixelFormat).
[in]widthWidth of texture image.
[in]heightHeight of texture image.
[in]pixelFormatPixel format of captured image.

Implemented in david::StructuredLightScannerJsonRpc, and david::StructuredLightScannerD4Lib.


The documentation for this class was generated from the following file: