AnyGeometry¶
-
class AnyGeometry(data=
None, geometry_type=None, sly_id=None, class_id=None, labeler_login=None, updated_at=None, created_at=None)[source]¶ Bases:
GeometryPlaceholder geometry that accepts any shape type. Used for labels with flexible geometry. Immutable.
Methods
Returns the allowed transforms for the Geometry.
Clone from GEOMETRYYY
Convert geometry config from json format
Convert geometry config to json format
Convert geometry to another geometry shape.
cropDraws the figure contour on a given bitmap canvas :param bitmap: np.ndarray :param color: [R, G, B] :param thickness: (int) :param config: drawing config specific to a concrete subclass, e.g. per edge colors.
fliplrflipudfrom_jsonGeometry name.
Returns 2D boolean mask of the geometry.
Get the name of the geometry.
Crops object like "crop" method, but return results with coordinates relative to rect :param rect: Rectangle for crop.
resizerotatescaleto_bboxto_jsontranslateValidate geometry.
Attributes
arearaw_geometry_type- classmethod allowed_transforms()¶
Returns the allowed transforms for the Geometry.
- classmethod name()¶
Get the name of the geometry.
Same as
geometry_name(), but shorter. In order to make the code more concise.- Returns:
string with name of geometry
- clone()¶
Clone from GEOMETRYYY
-
convert(new_geometry, contour_radius=
0, approx_epsilon=None)¶ Convert geometry to another geometry shape.
-
draw_contour(bitmap, color, thickness=
1, config=None)¶ Draws the figure contour on a given bitmap canvas :param bitmap: np.ndarray :param color: [R, G, B] :param thickness: (int) :param config: drawing config specific to a concrete subclass, e.g. per edge colors
- get_mask(img_size)¶
Returns 2D boolean mask of the geometry. With shape as img_size (height, width) and filled with True values inside the geometry and False values outside. dtype = np.bool shape = img_size
- relative_crop(rect)¶
Crops object like “crop” method, but return results with coordinates relative to rect :param rect: Rectangle for crop. :type rect:
Rectangle:returns: List of Geometry after relative crop. :rtype: List[Geometry]` :raises NotImplementedError: if method is not implemented in subclass
- validate(obj_class_shape, settings)¶
Validate geometry.
- Parameters:
- Raises:
ValueError – if geometry validation error