ReconstructMe SDK  2.6.43-0
Real-time 3D reconstruction engine
Surface

Compute a 3D triangle mesh from content of the reconstruction volume. More...

Typedefs

typedef int reme_surface_t
 Handle referencing a surface object. More...
 
reme_error_t reme_surface_create (reme_context_t c, reme_surface_t *s)
 Create a new surface object. More...
 
reme_error_t reme_surface_destroy (reme_context_t c, reme_surface_t *s)
 Destroy a previously created surface object. More...
 
reme_error_t reme_surface_bind_generation_options (reme_context_t c, reme_surface_t s, reme_options_t o)
 Access the surface generation options. More...
 
reme_error_t reme_surface_bind_poisson_options (reme_context_t c, reme_surface_t s, reme_options_t o)
 Access the poisson reconstruction options. More...
 
reme_error_t reme_surface_bind_decimation_options (reme_context_t c, reme_surface_t s, reme_options_t o)
 Access the surface decimation options. More...
 
reme_error_t reme_surface_bind_remesh_options (reme_context_t c, reme_surface_t s, reme_options_t o)
 Access the surface remeshing options. More...
 
reme_error_t reme_surface_bind_cleanup_options (reme_context_t c, reme_surface_t s, reme_options_t o)
 Access the surface cleanup options. More...
 
reme_error_t reme_surface_generate (reme_context_t c, reme_surface_t s, reme_volume_t v)
 Extract the iso-surface from the given volume. More...
 
reme_error_t reme_surface_poisson (reme_context_t c, reme_surface_t s)
 Perform poisson reconstruction on the extracted surface. More...
 
reme_error_t reme_surface_decimate (reme_context_t c, reme_surface_t s)
 Decimate the extracted surface. More...
 
reme_error_t reme_surface_remesh (reme_context_t c, reme_surface_t s)
 Remesh the extracted surface. More...
 
reme_error_t reme_surface_cleanup (reme_context_t c, reme_surface_t s)
 Cleanup the extracted surface. More...
 
reme_error_t reme_surface_transform (reme_context_t c, reme_surface_t s, const float *coordinates)
 Transform the surface. More...
 
reme_error_t reme_surface_colorize_vertices (reme_context_t c, reme_surface_t s, reme_volume_t v)
 Colorize surface vertices using the color information stored in the reconstruction volume. More...
 
reme_error_t reme_surface_inpaint_vertices (reme_context_t c, reme_surface_t s)
 Paint missing vertex colors. More...
 
reme_error_t reme_surface_get_points (reme_context_t c, reme_surface_t s, const float **coordinates, int *length)
 Get points of a surface. More...
 
reme_error_t reme_surface_get_normals (reme_context_t c, reme_surface_t s, const float **coordinates, int *length)
 Get point normals of a surface. More...
 
reme_error_t reme_surface_get_vertex_colors (reme_context_t c, reme_surface_t s, const float **coordinates, int *length)
 Get colors of surface vertices. More...
 
reme_error_t reme_surface_get_triangles (reme_context_t c, reme_surface_t s, const size_t **indices, int *length)
 Get triangle faces of a surface. More...
 
reme_error_t reme_surface_save_to_file (reme_context_t c, reme_surface_t s, const char *filename)
 Export the surface to file. More...
 
reme_error_t reme_surface_load_from_file (reme_context_t c, reme_surface_t s, const char *filename)
 Import surface from file. More...
 

Detailed Description

Compute a 3D triangle mesh from content of the reconstruction volume.

This modules provides methods to generate triangle meshes from reconstruction volumes. Besides basic surface extraction, hole closing and decimation functionality is provided.

The example below illustrates the functionality.

// Create a new empty surface
// We use an options object to control various aspects of the generation process
// Bind the options that define how the basic surface is extracted from the volume.
// We disable merging of close vertices at this stage because the data is directly
// passed into poisson reconstruction which deals with duplicate vertices anyway
reme_options_set_bool(c, o, "merge_duplicate_vertices", false);
// Extract surface from volume.
// Close holes through Poisson reconstruction
reme_options_set_int(c, o, "depth", 8);
// Reduce mesh down to 20k triangles
reme_options_set_int(c, o, "maximum_faces", 20000);
// View the result and wait until the user closes the viewer
reme_viewer_t viewer;
reme_viewer_create_surface(c, m, "This is ReconstructMeSDK", &viewer);
reme_viewer_wait(c, viewer);
// Export mesh
reme_surface_save_to_file(c, m, "test.ply");

Typedef Documentation

◆ reme_surface_t

typedef int reme_surface_t

Handle referencing a surface object.

A reme_surface_t represents a 3D mesh surface extracted from a volume. Its associated methods allow to influence the generation process, access mesh data and save volumes using our exporters.

Function Documentation

◆ reme_surface_create()

◆ reme_surface_destroy()

reme_error_t reme_surface_destroy ( reme_context_t  c,
reme_surface_t s 
)

Destroy a previously created surface object.

Parameters
cA pointer to a valid context object
sA mutable pointer to a valid surface handle to destroy
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_bust.cpp, example_reconstructmesdk_colorize.cpp, example_reconstructmesdk_marker.cpp, example_reconstructmesdk_one_minute.cpp, example_reconstructmesdk_point_and_shoot_with_colors.cpp, and example_reconstructmesdk_sensor_printing.cpp.

◆ reme_surface_bind_generation_options()

reme_error_t reme_surface_bind_generation_options ( reme_context_t  c,
reme_surface_t  s,
reme_options_t  o 
)

Access the surface generation options.

Associated Protocol Buffers Specification
// Surface generation from reconstruction volume
message generation_options {
// When enabled duplicate vertices within a certain radius are merged towards a single vertex.
optional bool merge_duplicate_vertices = 1 [default = true];
// Defines merge radius. Larger values will perform a simple decimation
optional float merge_radius = 2 [default = 0.00001];
}
Parameters
cA valid context object
sA valid surface object
oA valid options binding object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_surface.cpp.

◆ reme_surface_bind_poisson_options()

reme_error_t reme_surface_bind_poisson_options ( reme_context_t  c,
reme_surface_t  s,
reme_options_t  o 
)

Access the poisson reconstruction options.

Associated Protocol Buffers Specification
// Poisson surface generation options
message poisson_options {
// This integer is the maximum depth of the tree that will be used for surface reconstruction.
// Running at depth d corresponds to solving on a voxel grid whose resolution is no larger than 2^d x 2^d x 2^d.
// Note that since the reconstructor adapts the octree to the sampling density, the specified reconstruction depth is only an upper bound.
// The default value for this parameter is 8.
optional int32 depth = 1 [default = 8];
// Solver subdivision depth. This integer argument specifies the depth at which a block Gauss-Seidel solver is used to solve
// the Laplacian equation. Using this parameter helps reduce the memory overhead at the cost of a small
// increase in reconstruction time. (In practice, we have found that for reconstructions of depth 9 or higher a subdivide
// depth of 7 or 8 can greatly reduce the memory usage.) The default value is 8.
optional int32 solver_divide = 2 [default = 8];
// Iso-surface extraction subdivision depth. This integer argument specifies the depth at which a block iso-surface extractor should be used
// to extract the iso-surface. Using this parameter helps reduce the memory overhead at the cost of a
// small increase in extraction time. (In practice, we have found that for reconstructions of depth 9 or
// higher a subdivide depth of 7 or 8 can greatly reduce the memory usage.) The default value is 8.
optional int32 iso_divide = 3 [default = 8];
// Minimum number of samples per octree node. This floating point value specifies the minimum number of sample points that should fall within an octree
// node as the octree construction is adapted to sampling density. For noise-free samples, small values in
// the range [1.0 - 5.0] can be used. For more noisy samples, larger values in the range [15.0 - 20.0] may be
// needed to provide a smoother, noise-reduced, reconstruction. The default value is 1.0.
optional int32 minimum_samples_per_node = 4 [default = 1];
// Currently unused
optional float scale = 5 [default = 2.0];
// When enabled the output is a manifold
optional bool enable_manifold = 6 [default = true];
// M inimum reconstruction depth. This integer specifies the depth beyond depth the octree will be adapted. At coarser depths,
// the octree will be complete, containing all 2^d x 2^d x 2^d nodes. The default value for this parameter is 5.
optional int32 minimum_depth = 7 [default = 5];
}
Parameters
cA valid context object
sA valid surface object
oA valid options binding object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_options_type_safe.cpp, and example_reconstructmesdk_surface.cpp.

◆ reme_surface_bind_decimation_options()

reme_error_t reme_surface_bind_decimation_options ( reme_context_t  c,
reme_surface_t  s,
reme_options_t  o 
)

Access the surface decimation options.

Associated Protocol Buffers Specification
// Mesh decimation options
message decimation_options {
// Decimate to target complexity.
// Range: 0..inf
optional int32 maximum_faces = 1 [default = 100000];
// Maximum quadric error to accept per collapse. The quadric error is similar
// to the Hausdorff Distance.
// Range: 0..inf
optional float maximum_quadric_error = 2 [default = 100000];
// Minimum triangle roundness. Normalized triangle roundness with respect to
// equiliteral triangle shape.
// Range: 0..1
optional float minimum_triangle_roundness = 3 [default = 0];
// Maximum normal angle error in degrees.
// Range: 0..180
optional float maximum_angle_error = 4 [default = 90];
// Preserve the boundary of the mesh.
optional bool preserve_boundary = 5 [default = false];
// Preserve the boundary of the mesh.
optional float maximum_color_error = 6 [default = 765];
}
Parameters
cA valid context object
sA valid surface object
oA valid options binding object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_surface.cpp.

◆ reme_surface_bind_remesh_options()

reme_error_t reme_surface_bind_remesh_options ( reme_context_t  c,
reme_surface_t  s,
reme_options_t  o 
)

Access the surface remeshing options.

Associated Protocol Buffers Specification
// Mesh remeshing options
message remeshing_options {
// Minimum target edge length in remeshing.
// Range: 0..inf and -1.
// Leave at -1 to auto-calculate from average mesh edge length
optional float minimum_edge_length = 1 [default = -1];
// Maximum target edge length in remeshing.
// Range: 0..inf and -1.
// Leave at -1 to auto-calculate from average mesh edge length
optional float maximum_edge_length = 2 [default = -1];
// Maximum color error to tolerate in remeshing.
// If the error in color change when collapsing an edge is above
// this threshold, the collapse is not tolerated. Note that this property
// is only taken into account if the input mesh has vertex colors.
// Range 0..255*3
optional float maximum_color_error = 3 [default = 20.0];
// Maximum curfvate error to tolerate in remeshing.
// If the error in geometric change when collapsing an edge is above
// this threshold, the collapse is not tolerated.
// Range 0..1
optional float maximum_curvate_error = 4 [default = 0.5];
// Instead of adaptive remeshing perform a uniform remeshing.
// Use the maximum_edge_length property to control the target resolution.
// Note that maximum_color_error and maximum_curvate_error would be respected
// in this mode.
optional bool uniform = 5 [default = false];
// Number of iterations to apply.
optional int32 iterations = 6 [default = 5];
}
Parameters
cA valid context object
sA valid surface object
oA valid options binding object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_colorize.cpp.

◆ reme_surface_bind_cleanup_options()

reme_error_t reme_surface_bind_cleanup_options ( reme_context_t  c,
reme_surface_t  s,
reme_options_t  o 
)

Access the surface cleanup options.

Associated Protocol Buffers Specification
// Mesh cleanup options
message cleanup_options {
// Remove components with fewer faces than the given threshold.
// Range: 0..inf
optional int32 minimum_faces = 1 [default = 100];
// Remove components with a diameter less than the given threshold.
// The diameter is calculated based on the compoenents axis aligned
// bounding box.
// Range: 0..inf
optional float minimum_diameter = 2 [default = 0];
// Remove faces/vertices with no/invalid colorization.
optional bool delete_invalid_colorization = 3 [default = true];
}
Parameters
cA valid context object
sA valid surface object
oA valid options binding object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure

◆ reme_surface_generate()

reme_error_t reme_surface_generate ( reme_context_t  c,
reme_surface_t  s,
reme_volume_t  v 
)

Extract the iso-surface from the given volume.

The surface is generated with respect to the world coordinate system.

In case you are using an unlicensed version of ReconstructMe SDK, this function blocks for at least 15 seconds. Without this limitation the mesh is usually generated in under a second.

Parameters
cA valid context object
sA valid surface object
vA valid volume object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_bust.cpp, example_reconstructmesdk_colorize.cpp, example_reconstructmesdk_marker.cpp, example_reconstructmesdk_one_minute.cpp, example_reconstructmesdk_point_and_shoot_with_colors.cpp, example_reconstructmesdk_remote_reconstruction.cpp, example_reconstructmesdk_sensor_multi_independent.cpp, example_reconstructmesdk_sensor_printing.cpp, and example_reconstructmesdk_surface.cpp.

◆ reme_surface_poisson()

reme_error_t reme_surface_poisson ( reme_context_t  c,
reme_surface_t  s 
)

Perform poisson reconstruction on the extracted surface.

Use reme_surface_bind_poisson_options to control the decimation process.

Parameters
cA valid context object
sA valid surface object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_bust.cpp, example_reconstructmesdk_marker.cpp, example_reconstructmesdk_point_and_shoot_with_colors.cpp, and example_reconstructmesdk_surface.cpp.

◆ reme_surface_decimate()

reme_error_t reme_surface_decimate ( reme_context_t  c,
reme_surface_t  s 
)

Decimate the extracted surface.

Use reme_surface_bind_decimation_options to control the decimation process. If the input mesh has vertex colors those will be respected in the remesh process.

Note that after the decimation vertex colors will be incorrect. You should generate them again using reme_surface_colorize_vertices and reme_surface_inpaint_vertices.

In contrast to reme_surface_remesh this function only reduces the number of faces and does not generate an isotropic surface.

Parameters
cA valid context object
sA valid surface object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_surface.cpp.

◆ reme_surface_remesh()

reme_error_t reme_surface_remesh ( reme_context_t  c,
reme_surface_t  s 
)

Remesh the extracted surface.

Attempts to create an isotropic surface. Isotropic remeshing of surfaces tries to resample the surface to obtain a triangle tesselation, where the shape of each triangle is not biased in a particular direction (isotropy).

Use reme_surface_bind_remesh_options to control the remeshing process. If the input mesh has vertex colors those will be respected in the remesh process.

Parameters
cA valid context object
sA valid surface object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_colorize.cpp.

◆ reme_surface_cleanup()

reme_error_t reme_surface_cleanup ( reme_context_t  c,
reme_surface_t  s 
)

Cleanup the extracted surface.

Removes small unconnected components from the given surface. See reme_surface_bind_cleanup_options for usable parameters.

Parameters
cA valid context object
sA valid surface object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_bust.cpp, and example_reconstructmesdk_marker.cpp.

◆ reme_surface_transform()

reme_error_t reme_surface_transform ( reme_context_t  c,
reme_surface_t  s,
const float *  coordinates 
)

Transform the surface.

This will transform the points and normals of the surface.

Parameters
cA valid context object
sA valid surface object
coordinatesA pointer to constant Transform data.
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_bust.cpp.

◆ reme_surface_colorize_vertices()

reme_error_t reme_surface_colorize_vertices ( reme_context_t  c,
reme_surface_t  s,
reme_volume_t  v 
)

Colorize surface vertices using the color information stored in the reconstruction volume.

Colorizes all vertices of the given surface. Before calling this method you need to at least generate a surface using reme_surface_generate. It's possible to use a modified version of the surface. E.g you can even pass a poisson-reconstructed surface.

Vertices with missing color information receive a unique color which is currently green (in RGBA: 0/255/0/0). Use the reme_surface_inpaint_vertices to generate missing vertex colors.

Parameters
cA valid context object
sA valid surface object
vA valid volume object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_NO_COLOR_SUPPORTSetup does not support colors.
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_bust.cpp, example_reconstructmesdk_colorize.cpp, example_reconstructmesdk_marker.cpp, example_reconstructmesdk_point_and_shoot_with_colors.cpp, and example_reconstructmesdk_remote_reconstruction.cpp.

◆ reme_surface_inpaint_vertices()

reme_error_t reme_surface_inpaint_vertices ( reme_context_t  c,
reme_surface_t  s 
)

Paint missing vertex colors.

Vertices without a valid vertex color will be painted by an algorithm that tries to use surrounding color information. A vertex is said to have no color or an invalid color if the color is exactly green (in RGBA: 0/255/0/0).

Parameters
cA valid context object
sA valid surface object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_NO_COLOR_SUPPORTSetup does not support colors.
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_bust.cpp, example_reconstructmesdk_colorize.cpp, example_reconstructmesdk_marker.cpp, and example_reconstructmesdk_point_and_shoot_with_colors.cpp.

◆ reme_surface_get_points()

reme_error_t reme_surface_get_points ( reme_context_t  c,
reme_surface_t  s,
const float **  coordinates,
int *  length 
)

Get points of a surface.

The surface points are represented as an array of floats where each point consists of 4 coordinates Px Py Pz Pw Px Py Pz Pw ... . The w component is always zero.

Note the i-th point starts at index i * 4 of coordinate array returned.

Memory Management Rules Exception

The returned coordinates pointer remains valid until the mesh changes.

Parameters
cA valid context object
sA valid surface object
coordinatesA mutable pointer to constant point data.
lengthThe number of coordinates returned. To get the number of points divide this value by 4.
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure

◆ reme_surface_get_normals()

reme_error_t reme_surface_get_normals ( reme_context_t  c,
reme_surface_t  s,
const float **  coordinates,
int *  length 
)

Get point normals of a surface.

The surface point normals are represented as an array of floats where each point consists of 4 coordinates Px Py Pz Pw Px Py Pz Pw ... . The w component is always zero.

Note the i-th point normal starts at index i * 4 of coordinate array returned.

Memory Management Rules Exception

The returned coordinates pointer remains valid until the mesh changes.

Parameters
cA valid context object
sA valid surface object
coordinatesA mutable pointer to constant point normal data.
lengthThe number of coordinates returned. To get the number of point normals divide this value by 4.
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure

◆ reme_surface_get_vertex_colors()

reme_error_t reme_surface_get_vertex_colors ( reme_context_t  c,
reme_surface_t  s,
const float **  coordinates,
int *  length 
)

Get colors of surface vertices.

The surface vertex colors are represented as an array of floats where each color consists of 4 coordinates R G B A R G B A ... . The A component is always zero. The range of each channel is between zero and one.

Note the i-th color starts at index i * 4 of coordinate array returned. The returned array might be empty if no colors are have been generated through reme_surface_colorize_vertices or colors are not supported by the current setup. Vertices that don't have a valid color will carry an invalid color represented as 0 1 0 0 .

Memory Management Rules Exception

The returned coordinates pointer remains valid until the mesh changes.

Parameters
cA valid context object
sA valid surface object
coordinatesA mutable pointer to constant color data.
lengthThe number of coordinates returned. To get the number of colors divide this value by 4.
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure

◆ reme_surface_get_triangles()

reme_error_t reme_surface_get_triangles ( reme_context_t  c,
reme_surface_t  s,
const size_t **  indices,
int *  length 
)

Get triangle faces of a surface.

The triangle faces are represented as an array of unsigned integers (point indices) where each triangle consists of 3 indices that represent that points that make up each face P0 P1 P2 P0 P1 P2 ... .

Note the i-th triangle starts at index i * 3 of index array returned.

Memory Management Rules Exception

The returned indices pointer remains valid until the mesh changes.

Parameters
cA valid context object
sA valid surface object
indicesA mutable pointer to constant triangle index data.
lengthThe number of indices returned. To get the number of triangles divide this value by 3.
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure

◆ reme_surface_save_to_file()

reme_error_t reme_surface_save_to_file ( reme_context_t  c,
reme_surface_t  s,
const char *  filename 
)

Export the surface to file.

The exporter is chosen based on the file extension. Currently supported are

  • .PLY - Polygon File Format
  • .STL - StereoLithography
  • .OBJ - Wavefront
  • .3DS - 3D Studio Max

When exporting a vertex-colored mesh in .OBJ file format, the method will currently automatically bake vertex colors to a texture and save the textured mesh. This feature is considered beta and there is currently no way of configuring individual steps in this pipeline or retrieve texture related results in memory.

Parameters
cA valid context object
sA valid surface object
filenameFilename to save mesh as
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_bust.cpp, example_reconstructmesdk_colorize.cpp, example_reconstructmesdk_marker.cpp, example_reconstructmesdk_one_minute.cpp, example_reconstructmesdk_point_and_shoot_with_colors.cpp, example_reconstructmesdk_sensor_multi_independent.cpp, example_reconstructmesdk_sensor_printing.cpp, and example_reconstructmesdk_surface.cpp.

◆ reme_surface_load_from_file()

reme_error_t reme_surface_load_from_file ( reme_context_t  c,
reme_surface_t  s,
const char *  filename 
)

Import surface from file.

The importer is chosen based on the file extension. Currently supported are

  • .PLY - Polygon File Format
  • .STL - StereoLithography
  • .OBJ - Wavefront
  • .3DS - 3D Studio Max
Parameters
cA valid context object
sA valid surface object
filenameFilename to load mesh from
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_colorize.cpp.