robokudo.utils.shape_estimator_adapters ======================================= .. py:module:: robokudo.utils.shape_estimator_adapters .. autoapi-nested-parse:: Shape-specific adapters for fitted primitive results. Attributes ---------- .. autoapisummary:: robokudo.utils.shape_estimator_adapters.ShapeFitParameters robokudo.utils.shape_estimator_adapters.SPHERE_FIT_ADAPTER robokudo.utils.shape_estimator_adapters.CYLINDER_FIT_ADAPTER robokudo.utils.shape_estimator_adapters.CUBOID_FIT_ADAPTER robokudo.utils.shape_estimator_adapters.SHAPE_FIT_ADAPTERS Classes ------- .. autoapisummary:: robokudo.utils.shape_estimator_adapters.SphereFitParameters robokudo.utils.shape_estimator_adapters.CylinderFitParameters robokudo.utils.shape_estimator_adapters.CuboidFitParameters robokudo.utils.shape_estimator_adapters.ShapeFitSummary robokudo.utils.shape_estimator_adapters.SphereFitSummary robokudo.utils.shape_estimator_adapters.CylinderFitSummary robokudo.utils.shape_estimator_adapters.CuboidFitSummary robokudo.utils.shape_estimator_adapters.ShapeFitAdapter robokudo.utils.shape_estimator_adapters.SphereFitAdapter robokudo.utils.shape_estimator_adapters.CylinderFitAdapter robokudo.utils.shape_estimator_adapters.CuboidFitAdapter Functions --------- .. autoapisummary:: robokudo.utils.shape_estimator_adapters.adapter_for_fit robokudo.utils.shape_estimator_adapters.rotation_matrix_from_axis robokudo.utils.shape_estimator_adapters._format_summary_value robokudo.utils.shape_estimator_adapters._coordinate_frame robokudo.utils.shape_estimator_adapters._as_sphere_fit robokudo.utils.shape_estimator_adapters._as_cylinder_fit robokudo.utils.shape_estimator_adapters._as_cuboid_fit robokudo.utils.shape_estimator_adapters._as_sphere_fit_parameters robokudo.utils.shape_estimator_adapters._as_cylinder_fit_parameters robokudo.utils.shape_estimator_adapters._as_cuboid_fit_parameters Module Contents --------------- .. py:class:: SphereFitParameters Parameters for fitting one sphere candidate. .. py:attribute:: distance_threshold :type: float .. py:attribute:: robust_loss :type: str .. py:attribute:: max_radius :type: float .. py:attribute:: max_radius_to_bbox_diagonal_ratio :type: float .. py:attribute:: max_radius_to_observed_extent_ratio :type: float .. py:attribute:: max_center_distance_to_bbox_diagonal_ratio :type: float .. py:attribute:: min_inlier_ratio :type: float .. py:class:: CylinderFitParameters Parameters for fitting one cylinder candidate. .. py:attribute:: distance_threshold :type: float .. py:attribute:: robust_loss :type: str .. py:attribute:: max_radius :type: float .. py:attribute:: max_height :type: float .. py:attribute:: max_radius_to_bbox_diagonal_ratio :type: float .. py:attribute:: max_radius_to_cross_section_extent_ratio :type: float .. py:attribute:: max_axis_center_distance_to_bbox_diagonal_ratio :type: float .. py:attribute:: min_inlier_ratio :type: float .. py:attribute:: max_initializations :type: int .. py:attribute:: consensus_trials :type: int .. py:attribute:: inlier_polishing_iterations :type: int .. py:class:: CuboidFitParameters Parameters for fitting one cuboid candidate. .. py:attribute:: distance_threshold :type: float .. py:attribute:: max_extent :type: float .. py:attribute:: min_inlier_ratio :type: float .. py:data:: ShapeFitParameters .. py:class:: ShapeFitSummary Bases: :py:obj:`abc.ABC` Shared compact metrics for one fitted shape candidate. .. py:attribute:: score :type: float Fit quality score. .. py:attribute:: inlier_ratio :type: float Ratio of input points explained by the fitted shape. .. py:attribute:: root_mean_square_error :type: float Root mean square distance error of inlier points. .. py:property:: shape_name :type: str :abstractmethod: Name of the fitted shape. .. py:method:: shape_specific_fields() -> tuple[tuple[str, object, str | None], Ellipsis] :abstractmethod: Return fields that only apply to this fitted shape. .. py:method:: __str__() -> str Return the compact log representation. .. py:class:: SphereFitSummary Bases: :py:obj:`ShapeFitSummary` Compact metrics for one fitted sphere candidate. .. py:attribute:: radius :type: float Fitted sphere radius. .. py:property:: shape_name :type: str Name of the fitted shape. .. py:method:: shape_specific_fields() -> tuple[tuple[str, object, str | None], Ellipsis] Return fields that only apply to this fitted shape. .. py:class:: CylinderFitSummary Bases: :py:obj:`ShapeFitSummary` Compact metrics for one fitted cylinder candidate. .. py:attribute:: radius :type: float Fitted cylinder radius. .. py:attribute:: height :type: float Fitted cylinder height. .. py:property:: shape_name :type: str Name of the fitted shape. .. py:method:: shape_specific_fields() -> tuple[tuple[str, object, str | None], Ellipsis] Return fields that only apply to this fitted shape. .. py:class:: CuboidFitSummary Bases: :py:obj:`ShapeFitSummary` Compact metrics for one fitted cuboid candidate. .. py:attribute:: extents :type: list[float] Fitted cuboid side lengths. .. py:property:: shape_name :type: str Name of the fitted shape. .. py:method:: shape_specific_fields() -> tuple[tuple[str, object, str | None], Ellipsis] Return fields that only apply to this fitted shape. .. py:class:: ShapeFitAdapter Bases: :py:obj:`abc.ABC` Shape-specific behavior for one fitted primitive type. .. py:attribute:: shape_name :type: str .. py:method:: matches(fit_result: robokudo.utils.shape_fitting.FittedShape) -> bool :abstractmethod: Return whether this adapter handles the fit result. .. py:method:: fit(points: numpy.ndarray, parameters: ShapeFitParameters) -> typing_extensions.Optional[robokudo.utils.shape_fitting.FittedShape] :abstractmethod: Fit this primitive using shape-specific fit parameters. .. py:method:: to_annotation(fit_result: robokudo.utils.shape_fitting.FittedShape) -> robokudo.types.annotation.Shape :abstractmethod: Convert a fit result into a RoboKudo shape annotation. .. py:method:: to_o3d_geometry(fit_result: robokudo.utils.shape_fitting.FittedShape) -> open3d.geometry.Geometry :abstractmethod: Convert a fitted primitive into an Open3D geometry. .. py:method:: to_coordinate_frame(fit_result: robokudo.utils.shape_fitting.FittedShape) -> open3d.geometry.TriangleMesh :abstractmethod: Create a coordinate frame located at the fitted primitive center. .. py:method:: summary(fit_result: robokudo.utils.shape_fitting.FittedShape) -> ShapeFitSummary :abstractmethod: Return compact metrics for one fitted candidate. .. py:class:: SphereFitAdapter Bases: :py:obj:`ShapeFitAdapter` Adapter for sphere fit results. .. py:attribute:: shape_name :value: 'Sphere' .. py:method:: matches(fit_result: robokudo.utils.shape_fitting.FittedShape) -> bool Return whether this adapter handles the fit result. .. py:method:: fit(points: numpy.ndarray, parameters: ShapeFitParameters) -> typing_extensions.Optional[robokudo.utils.shape_fitting.SphereFit] Fit one sphere candidate. .. py:method:: to_annotation(fit_result: robokudo.utils.shape_fitting.FittedShape) -> robokudo.types.annotation.Sphere Create a sphere annotation from a sphere fit. .. py:method:: to_o3d_geometry(fit_result: robokudo.utils.shape_fitting.FittedShape) -> open3d.geometry.Geometry Convert a fitted sphere into an Open3D geometry. .. py:method:: to_coordinate_frame(fit_result: robokudo.utils.shape_fitting.FittedShape) -> open3d.geometry.TriangleMesh Create a coordinate frame at the fitted sphere center. .. py:method:: summary(fit_result: robokudo.utils.shape_fitting.FittedShape) -> SphereFitSummary Return compact metrics for one sphere fit. .. py:class:: CylinderFitAdapter Bases: :py:obj:`ShapeFitAdapter` Adapter for cylinder fit results. .. py:attribute:: shape_name :value: 'Cylinder' .. py:method:: matches(fit_result: robokudo.utils.shape_fitting.FittedShape) -> bool Return whether this adapter handles the fit result. .. py:method:: fit(points: numpy.ndarray, parameters: ShapeFitParameters) -> typing_extensions.Optional[robokudo.utils.shape_fitting.CylinderFit] Fit one cylinder candidate. .. py:method:: to_annotation(fit_result: robokudo.utils.shape_fitting.FittedShape) -> robokudo.types.annotation.Cylinder Create a cylinder annotation from a cylinder fit. .. py:method:: to_o3d_geometry(fit_result: robokudo.utils.shape_fitting.FittedShape) -> open3d.geometry.Geometry Convert a fitted cylinder into an Open3D geometry. .. py:method:: to_coordinate_frame(fit_result: robokudo.utils.shape_fitting.FittedShape) -> open3d.geometry.TriangleMesh Create a coordinate frame at the fitted cylinder center. .. py:method:: summary(fit_result: robokudo.utils.shape_fitting.FittedShape) -> CylinderFitSummary Return compact metrics for one cylinder fit. .. py:class:: CuboidFitAdapter Bases: :py:obj:`ShapeFitAdapter` Adapter for cuboid fit results. .. py:attribute:: shape_name :value: 'Cuboid' .. py:method:: matches(fit_result: robokudo.utils.shape_fitting.FittedShape) -> bool Return whether this adapter handles the fit result. .. py:method:: fit(points: numpy.ndarray, parameters: ShapeFitParameters) -> typing_extensions.Optional[robokudo.utils.shape_fitting.CuboidFit] Fit one cuboid candidate. .. py:method:: to_annotation(fit_result: robokudo.utils.shape_fitting.FittedShape) -> robokudo.types.annotation.Cuboid Create a cuboid annotation from a cuboid fit. .. py:method:: to_o3d_geometry(fit_result: robokudo.utils.shape_fitting.FittedShape) -> open3d.geometry.Geometry Convert a fitted cuboid into an Open3D geometry. .. py:method:: to_coordinate_frame(fit_result: robokudo.utils.shape_fitting.FittedShape) -> open3d.geometry.TriangleMesh Create a coordinate frame at the fitted cuboid center. .. py:method:: summary(fit_result: robokudo.utils.shape_fitting.FittedShape) -> CuboidFitSummary Return compact metrics for one cuboid fit. .. py:data:: SPHERE_FIT_ADAPTER .. py:data:: CYLINDER_FIT_ADAPTER .. py:data:: CUBOID_FIT_ADAPTER .. py:data:: SHAPE_FIT_ADAPTERS .. py:function:: adapter_for_fit(fit_result: robokudo.utils.shape_fitting.FittedShape) -> ShapeFitAdapter Return the adapter for a fitted primitive. .. py:function:: rotation_matrix_from_axis(axis_direction: numpy.ndarray) -> numpy.ndarray Create an orthonormal rotation matrix with z aligned to the axis. .. py:function:: _format_summary_value(value: object, format_spec: str | None) -> str Format one summary value for compact log output. .. py:function:: _coordinate_frame(center: numpy.ndarray, rotation_matrix: numpy.ndarray, frame_size: float) -> open3d.geometry.TriangleMesh Create a transformed Open3D coordinate frame. .. py:function:: _as_sphere_fit(fit_result: robokudo.utils.shape_fitting.FittedShape) -> robokudo.utils.shape_fitting.SphereFit .. py:function:: _as_cylinder_fit(fit_result: robokudo.utils.shape_fitting.FittedShape) -> robokudo.utils.shape_fitting.CylinderFit .. py:function:: _as_cuboid_fit(fit_result: robokudo.utils.shape_fitting.FittedShape) -> robokudo.utils.shape_fitting.CuboidFit .. py:function:: _as_sphere_fit_parameters(parameters: ShapeFitParameters) -> SphereFitParameters .. py:function:: _as_cylinder_fit_parameters(parameters: ShapeFitParameters) -> CylinderFitParameters .. py:function:: _as_cuboid_fit_parameters(parameters: ShapeFitParameters) -> CuboidFitParameters