Skip to content

segment_object_model_3dSegmentObjectModel3dSegmentObjectModel3dsegment_object_model_3dT_segment_object_model_3d🔗

Short description🔗

segment_object_model_3dSegmentObjectModel3dSegmentObjectModel3dsegment_object_model_3dT_segment_object_model_3d — Segment a set of 3D points into sub-sets with similar characteristics.

Signature🔗

segment_object_model_3d( object_model_3d ObjectModel3D, attribute.name GenParamName, attribute.name GenParamValue, out object_model_3d ObjectModel3DOut )void SegmentObjectModel3d( const HTuple& ObjectModel3D, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* ObjectModel3DOut )static void HOperatorSet.SegmentObjectModel3d( HTuple objectModel3D, HTuple genParamName, HTuple genParamValue, out HTuple objectModel3DOut )def segment_object_model_3d( object_model_3d: MaybeSequence[HHandle], gen_param_name: Sequence[str], gen_param_value: Sequence[Union[str, float, int]] ) -> Sequence[HHandle]

def segment_object_model_3d_s( object_model_3d: MaybeSequence[HHandle], gen_param_name: Sequence[str], gen_param_value: Sequence[Union[str, float, int]] ) -> HHandleHerror T_segment_object_model_3d( const Htuple ObjectModel3D, const Htuple GenParamName, const Htuple GenParamValue, Htuple* ObjectModel3DOut )

static HObjectModel3DArray HObjectModel3D::SegmentObjectModel3d( const HObjectModel3DArray& ObjectModel3D, const HTuple& GenParamName, const HTuple& GenParamValue )

HObjectModel3D HObjectModel3D::SegmentObjectModel3d( const HTuple& GenParamName, const HTuple& GenParamValue ) const

static HObjectModel3D[] HObjectModel3D.SegmentObjectModel3d( HObjectModel3D[] objectModel3D, HTuple genParamName, HTuple genParamValue )

HObjectModel3D HObjectModel3D.SegmentObjectModel3d( HTuple genParamName, HTuple genParamValue )

Description🔗

The operator segment_object_model_3dSegmentObjectModel3d segments a set of 3D points given by a 3D object model with the handle ObjectModel3DobjectModel3Dobject_model_3d into several sub-sets of neighbored 3D points with similar characteristics like the same normal orientation or curvature. By default, the operator then tries to fit a 3D primitive, i.e., a simple 3D shape like a plane, a sphere, or a cylinder, into each of these sub-sets. As result, the operator returns a tuple of handles for the 3D object models that represent the individual sub-sets of 3D points (ObjectModel3DOutobjectModel3DOutobject_model_3dout). Within these 3D object models information is stored that concern, e.g., the success of the fitting and the type and parameters of the fitted 3D primitive. This information can be queried from the individual 3D object model with get_object_model_3d_paramsGetObjectModel3dParams.

Before calling segment_object_model_3dSegmentObjectModel3d, the input 3D object model should be prepared for the segmentation using the operator prepare_object_model_3dPrepareObjectModel3d with the parameter Purposepurposepurpose set to 'segmentation'"segmentation". If the input 3D object model is not prepared this way, the operator prepare_object_model_3dPrepareObjectModel3d is called internally within segment_object_model_3dSegmentObjectModel3d to extend the 3D object model with attributes that were not explicitly but only implicitly contained in the 3D object model.

To control the segmentation and the fitting, you can adjust some generic parameters within GenParamNamegenParamNamegen_param_name and GenParamValuegenParamValuegen_param_value. But note that for a lot of applications the default values are sufficient and no adjustment is necessary. The following values for GenParamNamegenParamNamegen_param_name and GenParamValuegenParamValuegen_param_value are possible:

  • 'max_orientation_diff'"max_orientation_diff": The parameter specifies the maximum angle between the point normals of two neighbored 3D points (in radians) that is allowed so that the two points belong to the same sub-set of 3D points. For a cylinder or sphere, the parameter value depends on the dimension of the object and on the distance of the neighbored 3D points. I.e., if the cylinder or sphere has a very small radius or if the 3D points are not very dense, the value must be chosen higher. For a plane the value is independent from the dimension of the object and can be set to a small value.

    Suggested values: 0.100.10, 0.150.15, 0.200.20

    Default: 0.150.15

  • 'max_curvature_diff'"max_curvature_diff": The parameter specifies the maximum difference between the curvatures of the surface at the positions of two neighbored 3D points that is allowed so that the two points belong to the same sub-set of 3D points. The value depends on the noise of the 3D points. I.e., if the noise level of the 3D points is very high, the value must be set to a higher value. Generally, the number of resulting 3D object models decreases for a higher value, because more 3D points are merged to a sub-set of 3D points.

    Suggested values: 0.030.03, 0.040.04, 0.050.05

    Default: 0.050.05

  • 'min_area'"min_area": The parameter specifies the minimum number of 3D points needed for a sub-set of connected 3D points to be returned by the segmentation. Thus, for a sub-set with fewer points the points are deleted and no output handle is created.

    Suggested values: 11, 1010, 100100

    Default: 100100

  • 'fitting'"fitting": The parameter specifies whether after the segmentation 3D primitives are fitted into the sub-sets of 3D points. If 'fitting'"fitting" is set to 'true'"true", which is the default, the fitting is calculated and the 3D object models with the resulting handles contain the parameters of the corresponding 3D primitives. The output parameters of a cylinder, a sphere, or a plane are described with the operator fit_primitives_object_model_3dFitPrimitivesObjectModel3d. If 'fitting'"fitting" is set to 'false'"false", only a segmentation is performed and the output 3D object models contain the segmented sub-sets of 3D points. A later fitting can be performed with the operator fit_primitives_object_model_3dFitPrimitivesObjectModel3d.

    List of values: 'false'"false", 'true'"true"

    Default: 'true'"true"

  • 'output_xyz_mapping'"output_xyz_mapping": The parameter determines if a mapping from the segmented 3D points to image coordinates is copied to the output 3D object model. This information is needed, e.g., when using the operator object_model_3d_to_xyzObjectModel3dToXyz after the segmentation (e.g., for a visualization). If 'output_xyz_mapping'"output_xyz_mapping" is set to 'true'"true", the image coordinate mapping is copied. Note that the parameter is only valid, if the image coordinate mapping is available in the input 3D object model. Make sure that, if you derive the input 3D object model by copying it with the operator copy_object_model_3dCopyObjectModel3d from a 3D object model that contains such a mapping, the mapping is copied, too. Furthermore, the parameter is only valid, if the 3D points are copied to the output 3D object model, which is set with the parameter 'output_point_coord'"output_point_coord". If 'output_xyz_mapping'"output_xyz_mapping" is set to 'false'"false", the image coordinate mapping is not copied.

    List of values: 'true'"true", 'false'"false"

    Default: 'false'"false"

  • 'primitive_type'"primitive_type", 'fitting_algorithm'"fitting_algorithm",'min_radius'"min_radius", 'max_radius'"max_radius",'output_point_coord'"output_point_coord": These parameters are used, if 'fitting'"fitting" is set to 'true'"true", which is the default. The meaning and the use of these parameters is described with the operator fit_primitives_object_model_3dFitPrimitivesObjectModel3d.

  • 'surface_check'"surface_check": The parameter determines whether the surface of a triangulated input object model is checked regarding its conformity to the expected requirements. If the input 3D object model contains triangles that are topologically invalid an error message is raised. If the triangulation was created (triangulate_object_model_3dTriangulateObjectModel3d) or edited (e.g., by simplify_object_model_3dSimplifyObjectModel3d) by a HALCON operator, a surface check should not be necessary. The check can be disabled in order to enhance the runtime by setting 'surface_check'"surface_check" to 'false'"false".

    List of values: 'true'"true", 'false'"false"

    Default: 'true'"true"

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

ObjectModel3DobjectModel3Dobject_model_3d (input_control) object_model_3d(-array) → (handle)HTuple (HHandle)HObjectModel3D, HTuple (IntPtr)MaybeSequence[HHandle]Htuple (handle)

Handle of the input 3D object model.

GenParamNamegenParamNamegen_param_name (input_control) attribute.name-array → (string)HTuple (HString)HTuple (string)Sequence[str]Htuple (char*)

Names of the generic parameters.

Number of elements: GenParamName == GenParamValue
List of values: 'fitting_algorithm', 'max_curvature_diff', 'max_orientation_diff', 'max_radius', 'min_area', 'min_radius', 'output_point_coord', 'output_xyz_mapping', 'primitive_type', 'surface_check'"fitting_algorithm", "max_curvature_diff", "max_orientation_diff", "max_radius", "min_area", "min_radius", "output_point_coord", "output_xyz_mapping", "primitive_type", "surface_check"

GenParamValuegenParamValuegen_param_value (input_control) attribute.name-array → (string / real / integer)HTuple (HString / double / Hlong)HTuple (string / double / int / long)Sequence[Union[str, float, int]]Htuple (char* / double / Hlong)

Values of the generic parameters.

Number of elements: GenParamValue == GenParamName
Suggested values: 0.15, 0.05, 100, 'true', 'false', 'cylinder', 'sphere', 'plane', 'all', 'least_squares', 'least_squares_huber', 'least_squares_tukey'0.15, 0.05, 100, "true", "false", "cylinder", "sphere", "plane", "all", "least_squares", "least_squares_huber", "least_squares_tukey"

ObjectModel3DOutobjectModel3DOutobject_model_3dout (output_control) object_model_3d(-array) → (handle)HTuple (HHandle)HObjectModel3D, HTuple (IntPtr)Sequence[HHandle]Htuple (handle)

Handle of the output 3D object model.

Result🔗

segment_object_model_3dSegmentObjectModel3d returns 2 (H_MSG_TRUE) if all parameter values are correct. If necessary, an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

xyz_to_object_model_3dXyzToObjectModel3d, read_object_model_3dReadObjectModel3d, prepare_object_model_3dPrepareObjectModel3d

Possible successors

get_object_model_3d_paramsGetObjectModel3dParams, object_model_3d_to_xyzObjectModel3dToXyz, write_object_model_3dWriteObjectModel3d, clear_object_model_3dClearObjectModel3d

See also

fit_primitives_object_model_3dFitPrimitivesObjectModel3d

Module🔗

3D Metrology