Geometry¶
- class Geometry[source]¶
Bases:
supervisely.io.json.JsonSerializable
Methods
allowed_transforms
Clone from GEOMETRYYY
config_from_json
config_to_json
convert
- param rect
Rectangle
- param bitmap
np.ndarray
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.
- param img_size
(rows, cols)
- param img_size
(rows, cols)
Deserialize from a JSON-compatible dict :param data: JSON-compatible dict :return: Parsed object
- return
string with name of geometry
Returns 2D boolean mask of the geometry.
Same as geometry_name(), but shorter.
Crops object like "crop" method, but return results with coordinates relative to rect :param rect: :return: list of Geometry
- param in_size
(rows, cols)
Rotates around image center -> New Geometry :param rotator: ImageRotator :return: Geometry
Scales around origin with a given factor.
- rtype
Serialize to JSON-compatible dict.
- param drow
int rows shift
validate
Attributes
- return
float
-
draw(bitmap, color, thickness=
1
, config=None
)[source]¶ - Parameters
- bitmap
np.ndarray
- color
[R, G, B]
- thickness
used only in Polyline and Point
- config
drawing config specific to a concrete subclass, e.g. per edge colors
-
draw_contour(bitmap, color, thickness=
1
, config=None
)[source]¶ 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
- classmethod from_json(data)¶
Deserialize from a JSON-compatible dict :param data: JSON-compatible dict :return: Parsed object
- get_mask(img_size)[source]¶
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
- classmethod name()[source]¶
Same as geometry_name(), but shorter. In order to make the code more concise.
- Returns
string with name of geometry
- relative_crop(rect)[source]¶
Crops object like “crop” method, but return results with coordinates relative to rect :param rect: :return: list of Geometry
- resize(in_size, out_size)[source]¶
- Parameters
- in_size
(rows, cols)
- out_size
(128, 256) (128, KEEP_ASPECT_RATIO) (KEEP_ASPECT_RATIO, 256)
- Returns
Geometry
- rotate(rotator)[source]¶
Rotates around image center -> New Geometry :param rotator: ImageRotator :return: Geometry
- scale(factor)[source]¶
Scales around origin with a given factor. :param: factor (float): :return: Geometry
- to_json()¶
Serialize to JSON-compatible dict. :return: dict
- property area¶
- Returns
float