find_deformable_surface_model — Find the best match of a deformable surface model in a 3D scene.
The operator find_deformable_surface_model finds the best match of the deformable surface model DeformableSurfaceModel in the 3D scene ObjectModel3D. The deformable surface model must have been created previously with, for example, create_deformable_surface_model.
The matching requires that the 3D object model ObjectModel3D contains points and normals. The following combinations are possible:
points and point normals
points and a 2D-Mapping, e.g. an XYZ image triple converted with xyz_to_object_model_3d
Note that triangles or polygons in the passed scene are ignored. Instead, only the vertices are used for matching. It is thus in general not recommended to use this operator on meshed scenes, such as CAD data. Instead, such a scene must be sampled beforehand using sample_object_model_3d to create points and normals. When using noisy point clouds, e.g., from time-of-flight cameras, the generic parameter 'scene_normal_computation' should be set to 'mls' in order to obtain more robust results (see below).
First, points are sampled uniformly from the scene passed in ObjectModel3D. The sampling distance is controlled with the parameter RelSamplingDistance, and is given relative to the diameter of the surface model. Decreasing RelSamplingDistance leads to more sampled points, and in turn to a more stable but slower matching. Increasing RelSamplingDistance reduces the number of sampled scene points, which leads to a less stable but faster matching. For an illustration showing different values for RelSamplingDistance, please refer to the operator create_deformable_surface_model.
The operator get_deformable_surface_matching_result can be used to retrieve the sampled scene points for visual inspection. For a robust matching it is recommended that at least 50-100 scene points are sampled for each object instance.
The method first finds an approximate position of the object. This position is then refined. The generic parameters controlling the deformation are described further down.
If a match was found, the score of the match is returned in Score and a deformable surface matching result handle is returned in DeformableSurfaceMatchingResult. Details of the matching result, such as the deformed model and the position of the reference points, can be queried with the operator get_deformable_surface_matching_result using the result handle. The returned result handle must be freed by using clear_deformable_surface_matching_result.
The score is normalized between 0 and 1 and represents the amount of model surface visible in the scene. A value of 1 represents a perfect match. The parameter MinScore can be used to filter the result. A match is returned only if its score exceeds the value of MinScore.
The parameters GenParamName and GenParamValue are used to set generic parameters. Both get a tuple of equal length, where the tuple passed to GenParamName contains the names of the parameters to set, and the tuple passed to GenParamValue contains the corresponding values. The possible parameter names and values are described below.
This parameter controls the normal computation of the sampled scene. In the default mode 'fast', normals are computed based on a small neighborhood of points. In the mode 'mls', normals are computed based on a larger neighborhood and using the more complex but more accurate 'mls' method. A more detailed description of the 'mls' method can be found in the description of the operator surface_normals_object_model_3d. The 'mls' mode is intended for noisy data, such as images from time-of-flight cameras.
Value list: 'fast', 'mls'
Default value: 'fast'
Number of iterations for the refinement. Increasing the number of iteration leads to a more accurate position at the expense of runtime. However, once convergence is reached, the accuracy can no longer be increased, even if the number of steps is increased.
Suggested values: 1, 10, 25, 50
Default value: 25
Assertion: 'pose_ref_num_steps' > 0
Set the distance threshold for refinement relative to the diameter of the surface model. Only scene points that are closer to the object than this distance are used for the optimization. Scene points further away are ignored.
Suggested values: 0.05, 0.1, 0.25, 0.3
Default value: 0.25
Assertion: 0 < 'pose_ref_dist_threshold_rel'
Set the distance threshold for scoring relative to the diameter of the surface model. See the following 'pose_ref_scoring_dist_abs' for a detailed description. Only one of the parameters 'pose_ref_scoring_dist_rel' and 'pose_ref_scoring_dist_abs' can be set. If both are set, only the value of the last parameter is used.
Suggested values: 0.1, 0.05, 0.03, 0.005
Default value: 0.03
Assertion: 0 < 'pose_ref_scoring_dist_rel'
Set the distance threshold for scoring. Only scene points that are closer to the object than this distance are considered to be 'on the model' when computing the score after the refinement. All other scene points are considered not to be on the model. The value should correspond to the amount of noise on the coordinates of the scene points. Only one of the parameters 'pose_ref_scoring_dist_rel' and 'pose_ref_scoring_dist_abs' can be set. If both are set, only the value of the last parameter is used.
This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.
Handle of the deformable surface model.
Handle of the 3D object model containing the scene.
Scene sampling distance relative to the diameter of the surface model.
Default value: 0.05
Suggested values: 0.1, 0.07, 0.05, 0.04, 0.03
Restriction: 0 < RelSamplingDistance < 1
Minimum score of the returned match.
Default value: 0
Restriction: MinScore >= 0
Names of the generic parameters.
Default value: 
List of values: 'pose_ref_dist_threshold_rel', 'pose_ref_num_steps', 'pose_ref_scoring_dist_abs', 'pose_ref_scoring_dist_rel', 'scene_normal_computation'
Values of the generic parameters.
Default value: 
Suggested values: 'fast', 'mls', 0, 1, 10, 25, 50, 0.05, 0.1, 0.25, 0.3, 0.05, 0.03, 0.005
Score of the found instances of the surface model.
Handle of the matching result.
find_deformable_surface_model returns 2 (H_MSG_TRUE) if all parameters are correct. If necessary, an exception is raised.
read_object_model_3d, xyz_to_object_model_3d, get_object_model_3d_params, read_deformable_surface_model, create_deformable_surface_model, get_deformable_surface_model_param, add_deformable_surface_model_reference_point, add_deformable_surface_model_sample
refine_deformable_surface_model, get_deformable_surface_matching_result, clear_deformable_surface_matching_result, clear_object_model_3d