MIL allows you to take the profile of a depth map or point cloud, along a specified slicing plane. This can be useful, for example, to analyze and verify the contour of an object's surface along a slice.
To take the 3D profile of a point cloud along a slicing plane, use M3dimProfile() with M_PROFILE_POINT_CLOUD. You must pass a transformation matrix that defines the slicing plane along which to extract points. You can establish this plane using M3dgeoMatrixSetWithAxes(). Specify a coordinate system whose XY-plane and origin are those of the required slicing plane; M3dgeoMatrixSetWithAxes() will generate the transformation matrix required to move from the XY-plane and origin of the working coordinate system to that of the specified coordinate system.
Note that the points in the profile do not necessarily fall exactly on the slicing plane. Instead, MIL subdivides the slicing plane into a grid and establishes the dimension of each grid's cell according to specified values, known as the sampling distance. For each cell, the point closest to the slicing plane is selected for the profile, as long as it is within a certain distance, known as the cutoff distance, from the plane.
To take the 3D profile of a depth map, use M3dimProfile() with M_PROFILE_DEPTH_MAP. You must pass the X- and Y-coordinates of the start and end points that define the line along which to extract points, represented in either world units (M_WORLD) or pixel units (M_PIXEL). The line is extended downwards, effectively defining a slicing plane, with the pixels' intensity values indicating depth (Z-values).
M3dimProfile() does not return points directly; instead, it stores the sampled points in a 3D image processing result buffer (M_PROFILE_RESULT). To retrieve these coordinates, call M3dimGetResult(). You can retrieve the X-, Y-, and Z-coordinates relative to the working coordinate system with M_WORLD_X, M_WORLD_Y, and M_WORLD_Z. Alternatively, you can retrieve the X- and Y- coordinates along the slicing plane, with respect to the origin of the plane, with M_PROFILE_PLANE_X and M_PROFILE_PLANE_Y. Note that for depth map profiles, since points are extracted along a specified line rather than an actual slicing plane, M_PROFILE_PLANE_X will return the real world distance along the specified line for each extracted point and M_PROFILE_PLANE_Y will return values that correspond to the depth at each pixel.
To take the profile of an object along a slicing plane that is at a known location on a reference object, you can:
Take a depth map of the object's point cloud using M3dimProject(). See the Generating fully corrected depth and intensity maps section later in this chapter for more information.
Find a model of a distinguishing feature on the object using MmodFind(). Note that since the Model Finder module works in 2D, the object is assumed to rotate only around its Z-axis, meaning it is always resting on the same side.
Retrieve the calibration fixture matrix that contains the transformation coefficients required to fixture to the found occurrence, using McalFixture() with M_MOVE_RELATIVE, the Model Finder result buffer, and a previously allocated transformation matrix object.
Apply the calibration fixture matrix to the object's point cloud so that it is at the same known position from the working coordinate system as the reference object is from its working coordinate system. To do so, use M3dimMatrixTransform().
Take the profile along the slicing plane using M3dimProfile() with M_PROFILE_POINT_CLOUD. Pass the transformation matrix that defines the slicing plane for the reference object.
Note that the profile could have been taken directly from the depth map. However, if vertical surfaces have been scanned, they will not appear in the depth map; they will only appear in the point cloud. In addition, if the point cloud includes both the top view and the bottom view of the object, the profile would include points along the bottom view. The following is an example of taking the profile of a serpentine belt tensioner along a slicing plane. The X- and Y-axes in the cross-sectional profile refer to the X- and Y-axes of the profile plane (M_PROFILE_PLANE_X and M_PROFILE_PLANE_Y), not the working coordinate system.
To analyze the surface of the object along the profile, you can fit one or more geometric shapes to it, such as a line and an arc, using the Metrology module. To add the profile points to a Metrology context, use MmetPut(). Since the points are not necessarily an ordered and connected chain, do not have MmetPut() automatically interpolate the gradient angle for the points (that is, set the ControlFlag parameter to M_DEFAULT). For more information, see the Using external edgels and points with constructed features section of Chapter 18: Metrology.
Note that the Metrology module can only analyze 2D points along the same plane (the X- and Y-coordinates). Therefore, to analyze the profile of an object along the plane, extract the coordinates of the points along the plane with respect to the plane's origin (M3dimGetResult() with M_PROFILE_PLANE_X and M_PROFILE_PLANE_Y), instead of with respect to the working coordinate system.
The following animation demonstrates how to define a 3D profile and then use the Metrology module to obtain certain measurements for analysis.