Compatibility

Import rangemaps from 3D cameras

SAL3D, in addition to have tools to create rangemaps using 2D cameras thanks to the peak detector, it is able to work with rangemaps coming from 3D cameras (like Automation Technology 3D cameras, or Ranger from Sick IVP).

Most 3D cameras provide their rangemaps as images with the profiles in rows, and the laser position encoded in gray colour. In that case, you can use the RangeMap constructor from frame: sal3d::RangeMap::RangeMap(const Frame &frame, int plane)

Note:
In case of using Photonfocus 3D cameras, SAL3D has an special peakfinder (phfpeakfinder) that extract the information from the camera frames

Import/Export to 2D libraries

SAL3D libraries allows to easily import and export frames with other libraries to benefit from existing funtionalities.

The combination of the ZMap data with 2D libraries allows the computation of 3D measures using fast and easy-to-use available tools.

zmap_before_rotation.png
zmap_hole_measure.png
ZMap2D circle fitting over a ZMap

Using the 2D tools, lots of measures can be computed (distance, area, diameters, etc.). All of them are represented in pixel units, however, in combination with the ZMapFactors, they can be converted to metric units. The previous image shows an example to compute the diameter of a hole after orientating the COP to get the hole plane parallel to the projection plane.

Importing frames from other libraries

SAL3D provides the tools needed to import images from other libraries. One only needs to know the format in which the image is stored in memory to create a Frame that handles that image.

All the details can be found in the sal3d::Frame documentation, but it is basically accomplished by using the Frame constructor from a pointer. The only requisite is knowing how the pixel information is stored in memory for the library that the user wants to take the picture from.

An example of how to create such a Frame can be found in Building a Frame from memory.

Exporting frames (also ZMaps) to other libraries

It should be relatively easy to export a sal3d::Frame to any other library, as long as it supports creating images from memory. As sal3d::ZMap objects can be converted to frames, this is the path to follow if one wants to do any kind of post-processing on a ZMap with any other library.

Along with SAL3D, some examples with source code showing how to export frames to other libraries are distributed. Specifically, there is an example showing how to save a ZMap to file using OpenCV (this could be easily achieved with only SAL3D, but it's just an example), and another example showing some post-process on a ZMap with MVTec's Halcon libraries.

Example of exporting a ZMap to OpenCV

This is a snippet from the OpenCV example showing how to convert a sal3d::ZMap to an image. In this case it is quite trivial thanks to the fact that the data in the ZMap is granted to be aligned in memory, but it should be possible to attain the same result with more complex cases.

    // open a ZMap from file and convert to Frame
    sal3d::ZMap zmap((std::string("filename")));
    sal3d::Frame frame(zmap.getFrame());

    // get the pointer to the data
    char *baseAddress;
    sal3d::Frame::VPAT vpa;
    frame.vpa(0, &baseAddress, &vpa);

    // get the size of a row in memory (not necessarily width*elem_size because
    // of padding)
    int step = vpa[1].y - vpa[0].y;

    // create the actual OpenCV image
    cv::Mat image (cv::Size (frame.width (), frame.height ()),
            cv::DataType<float>::type, baseAddress, step);

Import/Export 3D files

Input File Formats

CAD Data

The SAL3D library allows the user to convert CAD data to COP, so, CAD models can be compared with acquired clouds of points on Match3D. Although Match3D does not directly allows CAD data as a input model, the user could use the CAD Import tool to get COPs from IGES or STL data.

See CAD Import Tool page for more information.

Output File Formats

The SAL3D library allows to user to store clouds of points in standard formats (STL and PLY formats) to let the user to open in other applications.

PLY File Format

PLY is a flexible file format to store 3D data. This format was created by the Stanford University Computer Graphics Laboratory (http://graphics.stanford.edu/data/3Dscanrep).

Note:
Although a generic PLY file can contain several type of polygons, and different types of properties (normal, color, etc.), SAL3D ply format only recognizes triangles and normal information.

Example Export ply format

SAL3D contains functions which export COP data to Binary and ASCII PLY formats ( sal3d::COP::exportToBinaryPLY (...) and sal3d::COP::exportToAsciiPLY (...))

Here there is an example of an export PLY, containing vertices, normal information for each vertex, and also a list of triangles that relates vertices.

Example
format ascii 1.0
element vertex 7
property float x
property float y
property float z
property float nx
property float ny
property float nz
element face 5
property list uchar uint vertex_indices
end_header
34.0766 6.59329 7.39615 -0.955372 -0.0272075 0.294149
34.0775 6.89633 7.65857 -0.929029 -0.00528929 0.369968
34.0729 6.99754 7.5759 -0.908104 0.216407 0.358489
34.0618 7.40212 7.50036 -0.935095 0.0565364 0.349857
34.0567 7.60442 7.47588 -0.947034 -0.0317196 0.319564
34.0554 7.70545 7.50752 -0.888145 -0.338687 0.310627
34.0633 7.80534 7.85921 -0.917867 0.0829428 0.388123
3 1 2 4
3 2 4 5
3 2 3 5
3 3 5 6
3 4 5 7