| MIL 10 Reference
| Customize Help
| Save Settings

M3dmapExtract



See also
Availability
Not available in MIL-Lite
Available in MIL

Available on Windows
Available on Linux

Available on Non-Matrox computer
Available on Matrox 4Sight-X
Available on Matrox 4Sight GP
Available on Matrox Supersight
function map Function map
Examples
Synopsis
Generate a depth map image and, optionally, an intensity map image from data stored in a 3D reconstruction result buffer.
Syntax
void M3dmapExtract(
MIL_ID Result3dmapId, //in
MIL_ID DepthMapImageBufId, //in
MIL_ID IntensityMapImageBufId, //in
MIL_INT64 Operation, //in
MIL_INT LabelOrIndex, //in
MIL_INT64 ControlFlag //in
)
Description

This function takes the accumulated scanned laser line data stored inside a result buffer and generates a depth map image, as well as an intensity map image, if required. The gray level of the depth map image indicates depth; whereas, the gray level in the intensity map image indicates luminosity.

For result buffers of type M_POINT_CLOUD_CONTAINER, you must set an extraction box, using M3dmapSetBox(), prior to calling M3dmapExtract(); otherwise an error is returned. M3dmapExtract() only uses those points inside the extraction box when generating the depth map.

M3dmapExtract() projects the point cloud on the XY-plane of the relative coordinate system of the M_POINT_CLOUD_CONTAINER result buffer. You can change the perspective of the depth map by transforming the relative coordinate system. For more information, see the Changing a depth map by transforming the relative coordinate system subsection of the Generating fully corrected depth and intensity maps section of Chapter 18: 3D reconstruction using laser line profiling.

Missing data points, due to different phenomena such as occlusion, form gaps in the generated depth map. Pixels corresponding to gaps are set to the maximum value of the specified buffer. You can have M3dmapExtract() fill these gap pixels with likely values. To do so, you must specify the order (mode) in which M3dmapExtract() should fill the gaps using M3dmapControl() with M_FILL_MODE. Then, use M_FILL_SHARP_ELEVATION_DEPTH to indicate whether the difference between the gap's boundaries is sharp or gradual. Sharp elevation gaps are filled by propagating one of the gap's boundaries. Gradual elevation gaps are filled by linear interpolation.

You can also choose to only fill the data gaps of a previously generated depth map image. To do so, first set the required fill mode (M3dmapControl() with M_FILL_MODE). Then, call M3dmapExtract() with M_FILL_MISSING_DATA_ONLY and pass a 3D reconstruction result buffer and the identifier of a depth map image buffer that contains data gaps. The 3D reconstruction result buffer need not be the one used to initially generate the depth map. This is because the result buffer is only needed for the information vital to the gap-filling functionality, such as the fill mode (M3dmapControl() with M_FILL_MODE).

If you know that the total laser line data exceeds available memory, you can gradually add some data to the depth map and intensity map. To do so, you must first enable cumulative extraction mode, using M3dmapControl() with M_EXTRACTION_CUMULATIVE. In this mode, you must clear the depth map image buffer (using MbufClear()) before the first call to M3dmapExtract(). To gradually add data to the depth map, you must iterate through filling up the result buffer with several calls to M3dmapAddScan(), extracting the data from the result buffer into a depth map using M3dmapExtract(), followed by clearing the result buffer, using M3dmapClear(). Once the result buffer is cleared of the previous iteration's laser line data, you can start to fill it again with new laser line data.

Note that in cumulative extraction mode, gap filling is disabled, and you must call M3dmapExtract() with M_FILL_MISSING_DATA_ONLY only after the necessary depth map data is accumulated.

Unlike most other functions that modify a MIL object, you can call this function concurrently from multiple threads on the same M_POINT_CLOUD_CONTAINER result buffer (Result3dmapId) without using a M_MUTEX object. This is valid as long as the LabelOrIndex parameter of the concurrent calls is set to a different index, and is not set to M_ALL.

Note that this function reference has not been updated for a MIL system added during a MIL update. Refer to the MIL system's release note to see if there is complementary information.
Parameters
This function is not supported on the selected boards.
Parameters
Result3dmapId

Specifies the identifier of the result buffer which contains the laser line data. Note that you can only specify a 3D reconstruction result buffer of type M_DEPTH_CORRECTED_DATA or M_POINT_CLOUD_CONTAINER.

DepthMapImageBufId

Specifies the identifier of the image buffer in which to store the depth map. The image buffer must be a 1-band, 8-bit or 16-bit unsigned buffer.

For an M_DEPTH_CORRECTED_DATA result buffer (partially corrected depth map), the X-size of the depth map buffer should be at least either the X-size or Y-size of the laser line images used to generate the data, depending on whether MimControl() with M_SCAN_LANE_DIRECTION is set to M_VERTICAL or M_HORIZONTAL, respectively. The Y-size of the depth map buffer should be at least the number of laser line images or the value of the M_MAX_FRAMES control type, whichever is smaller.

You can determine the required size of the depth map buffer using M3dmapGetResult() with M_CORRECTED_DEPTH_MAP_SIZE_X and M_CORRECTED_DEPTH_MAP_SIZE_Y. Similarly, you can determine the required buffer type with M_CORRECTED_DEPTH_MAP_BUFFER_TYPE.

In M_EXTRACTION_CUMULATIVE mode, the Y-size of the depth map buffer should be at least the total number of extracted laser lines after all the cumulative calls to M3dmapAddScan().

For an M_POINT_CLOUD_CONTAINER result buffer (fully corrected depth map), there are no restrictions on the X-size, Y-size, or type of the depth map buffer. However, to get a depth map which is meaningful, the buffer size and type should take into consideration the M_PIXEL_SIZE_X, M_PIXEL_SIZE_Y, and M_GRAY_LEVEL_SIZE_Z control types if the M_USER_DEFINED scale mode is specified.

This image buffer must not have a region of interest (ROI) associated with it. Using an image buffer with an ROI will cause an error.

IntensityMapImageBufId

Specifies the identifier of the intensity image buffer. The image buffer must have the same dimensions as the buffer specified for DepthMapImageBufId. In addition, the image buffer must be a 1-band, 8- or 16-bit unsigned buffer; the type and pixel depth must be the same as those of the image buffer used to extract laser line data. You can call M3dmapGetResult() with M_INTENSITY_MAP_BUFFER_TYPE to determine the expected type and pixel depth.

This image buffer must not have a region of interest (ROI) associated with it. Using an image buffer with an ROI will cause an error.

If you don't need to generate the intensity map, set this parameter to M_NULL.

Operation

Specifies the type of operation to perform. This parameter must be set to one of the following values:

function map For specifying the operation
CollapseValue Description
Collapse M_CORRECTED_DEPTH_MAP

Generates either a fully or partially corrected depth map, depending on the type of the specified result buffer. An M_DEPTH_CORRECTED_DATA result buffer is used to generate a partially corrected depth map, and an M_POINT_CLOUD_CONTAINER result buffer is used to generate a fully corrected depth map.

Partially corrected depth maps accurately represent an object's depth (height) but not its shape, whereas fully corrected depth maps accurately represent both an object's depth (height) as well as its shape.

For fully corrected depth maps, this operation calibrates the destination buffer such that it has a constant pixel size.

Optionally, this operation can also generate an intensity map image, depending on the setting of IntensityMapImageBufId.

(summarize)
Collapse M_FILL_MISSING_DATA_ONLY

Fills in missing data points (gaps only) in a previously generated depth map image. A gap is an area of a depth map image that contains no depth information, but that corresponds to the area of an object for which there is a depth.

If in M_EXTRACTION_CUMULATIVE mode, you must only perform this operation after making all required calls to M3dmapExtract() to obtain the full depth map of the object.

(summarize)
Collapse M_UNCORRECTED_DEPTH_MAP

Draws the uncorrected depth map of an object generated using the acquired laser line data. In uncorrected depth maps, the gray value of a pixel inaccurately represents the object's depth in the world, and its shape is not corrected for the angle of the camera. Use M3dmapGetResult() with M_UNCORRECTED_DEPTH_MAP_SIZE_X, M_UNCORRECTED_DEPTH_MAP_SIZE_Y, and M_UNCORRECTED_DEPTH_MAP_BUFFER_TYPE to obtain the necessary buffer dimensions and type.

(summarize)
LabelOrIndex

Specifies the point cloud(s) in the specified 3D reconstruction result buffer from which to create a fully corrected depth map. Only 3D reconstruction result buffers allocated using M_POINT_CLOUD_CONTAINER have point clouds. For all other types of 3D reconstruction result buffers, set this parameter to M_DEFAULT.

function map For specifying the point cloud(s)
CollapseValue Description
Collapse

Specifies the index of a point cloud in the specified 3D reconstruction result buffer.

(summarize)
Parameters

Specifies the index of an existing point cloud.

Collapse

Specifies the label for a point cloud in the specified 3D reconstruction result buffer.

(summarize)
Parameters

Specifies the label of an existing point cloud.

Collapse M_ALL

Specifies to use all point clouds in the specified 3D reconstruction result buffer.

ControlFlag

Reserved for future expansion. This parameter must be set to M_DEFAULT.

Compilation information
Header Include mil.h.
Library Use mil.lib; mil3dmap.lib.
DLL Requires mil.dll; mil3dmap.dll.
UNSIGNED PROC NONE UNSIGNED PROC NONE UNSIGNED PROC NONE CORRECTED DEPTH MAP FILL MISSING DATA ONLY UNCORRECTED DEPTH MAP ALL