AnyGeometry¶
-
class AnyGeometry(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.
- Parameters:
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.
Crop the geometry with given rectangle.
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.
Deserialize from a JSON-compatible dict :param data: JSON-compatible dict :returns: Parsed object
Geometry 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.
Rotates around image center -> New Geometry :param rotator: Class for image rotation.
Scales around origin with a given factor.
Serialize to JSON-compatible dict.
Validate geometry.
Attributes
- classmethod allowed_transforms()¶
Returns the allowed transforms for the Geometry.
- classmethod from_json(data)¶
Deserialize from a JSON-compatible dict :param data: JSON-compatible dict :returns: Parsed object
- 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
- fliplr(img_size)¶
- Parameters:
- Returns:
Geometry after flip in horizontal.
- Return type:
- Raises:
NotImplementedError – if method is not implemented in subclass
- flipud(img_size)¶
- Parameters:
- Returns:
Geometry after flip in vertical.
- Return type:
- Raises:
NotImplementedError – if method is not implemented in subclass
- 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
- resize(in_size, out_size)¶
- Parameters:
- Returns:
Geometry after resize.
- Return type:
- Raises:
NotImplementedError – if method is not implemented in subclass
- rotate(rotator)¶
Rotates around image center -> New Geometry :param rotator: Class for image rotation. :type rotator:
ImageRotator:returns: Geometry after rotation. :rtype:Geometry
- scale(factor)¶
Scales around origin with a given factor. :param: factor: Scale factor. :type factor: float :returns:
Geometry:rtype:Geometry:raises NotImplementedError: if method is not implemented in subclass
- to_bbox()¶
- Returns:
Rectangle from geometry.
- Return type:
- Raises:
NotImplementedError – if method is not implemented in subclass
- to_json()¶
Serialize to JSON-compatible dict. :returns: dict
- validate(obj_class_shape, settings)¶
Validate geometry.
- Parameters:
- Raises:
ValueError – if geometry validation error
- property area¶
- Returns:
float