Cuboid3d

class Cuboid3d(position, rotation, dimensions, sly_id=None, class_id=None, labeler_login=None, updated_at=None, created_at=None)[source]

Bases: Geometry

3D cuboid with position, rotation, and dimensions (Vector3d). Immutable.

Cuboid3d is a geometry for a single Label. Cuboid3d object is immutable.

Parameters:
position

Vector3d.

rotation

Vector3d.

dimensions

Vector3d.

sly_id : int, optional

Cuboid3d ID in Supervisely server.

class_id : int, optional

ID of ObjClass to which Cuboid3d belongs.

labeler_login : str, optional

Login of the user who created Cuboid3d.

updated_at : str, optional

Date and Time when Cuboid3d was modified last. Date Format: Year:Month:Day:Hour:Minute:Seconds. Example: ‘2021-01-22T19:37:50.158Z’.

created_at : str, optional

Date and Time when Cuboid3d was created. Date Format is the same as in “updated_at” parameter.

Methods

allowed_transforms

Returns the allowed transforms for the Geometry.

clone

Clone from GEOMETRYYY

config_from_json

Convert geometry config from json format

config_to_json

Convert geometry config to json format

convert

Convert geometry to another geometry shape.

crop

Crop the geometry with given rectangle.

draw

draw_contour

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

flipud

from_json

Converts a JSON object to a Cuboid3d.

geometry_name

Returns the name of the geometry.

get_mask

Returns 2D boolean mask of the geometry.

name

Get the name of the geometry.

relative_crop

Crops object like "crop" method, but return results with coordinates relative to rect :param rect: Rectangle for crop.

resize

rotate

Rotates around image center -> New Geometry :param rotator: Class for image rotation.

scale

Scales around origin with a given factor.

to_bbox

to_json

Converts the Cuboid3d to a JSON object.

translate

validate

Validate geometry.

Attributes

area

dimensions

Copy of the dimensions of the Cuboid3d.

position

Copy of the position of the Cuboid3d.

rotation

Copy of the rotation of the Cuboid3d.

classmethod allowed_transforms()

Returns the allowed transforms for the Geometry.

classmethod from_json(data)[source]

Converts a JSON object to a Cuboid3d.

Parameters:
data : dict

JSON object

data

Cuboid3d in json format(dict)

Returns:

Cuboid3d

Return type:

Cuboid3d

Returns:

Cuboid3d from json.

Return type:

Cuboid3d

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

static config_from_json(config)

Convert geometry config from json format

Parameters:
config : dict

dictionary(geometry config) in json format

Returns:

dictionary(geometry config) in json format

Return type:

dict

static config_to_json(config)

Convert geometry config to json format

Parameters:
config : dict

dictionary(geometry config)

Returns:

dictionary(geometry config) in json format

Return type:

dict

static geometry_name()[source]

Returns the name of the geometry.

Returns:

name of the geometry

Return type:

str

clone()

Clone from GEOMETRYYY

convert(new_geometry, contour_radius=0, approx_epsilon=None)

Convert geometry to another geometry shape.

Parameters:
new_geometry

New geometry shape.

contour_radius : int

Radius of the contour.

approx_epsilon : float

Approximation epsilon.

Returns:

List of geometries.

Return type:

List[Geometry]

crop(rect)

Crop the geometry with given rectangle.

Parameters:
rect

Rectangle for crop.

Returns:

List of Geometry after crop.

Return type:

List[Geometry]`

draw(bitmap, color, thickness=1, config=None)
Parameters:
bitmap

np.ndarray

color

Color [R, G, B]

thickness=1

used only in Polyline and Point

config : dict

Drawing config specific to a concrete subclass, e.g. per edge colors

Raises:

NotImplementedError – if method is not implemented in subclass

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:
img_size : Tuple[int, int]

Image size (height, width) to which belongs Geometry.

Returns:

Geometry after flip in horizontal.

Return type:

Geometry

Raises:

NotImplementedError – if method is not implemented in subclass

flipud(img_size)
Parameters:
img_size : Tuple[int, int]

Image size (height, width) to which belongs Geometry.

Returns:

Geometry after flip in vertical.

Return type:

Geometry

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

Parameters:
img_size : Tuple[int, int]

size of the image (height, width)

Returns:

2D boolean mask of the geometry

Return type:

np.ndarray

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:
in_size : Tuple[int, int]

Input image size (height, width).

out_size : Tuple[int, int]

Desired output image size (height, width) of the Annotation to which Label belongs.

Returns:

Geometry after resize.

Return type:

Geometry

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:

Rectangle

Raises:

NotImplementedError – if method is not implemented in subclass

to_json()[source]

Converts the Cuboid3d to a JSON object.

Returns:

JSON object

Return type:

dict

Returns:

Cuboid3d in json format

translate(drow, dcol)
Parameters:
drow : int

Vertical shift.

dcol : int

Horizontal shift.

Returns:

Geometry after translate.

Return type:

Geometry

Raises:

NotImplementedError – if method is not implemented in subclass

validate(obj_class_shape, settings)

Validate geometry.

Parameters:
obj_class_shape : str

Object class shape.

settings : dict

Settings.

Raises:

ValueError – if geometry validation error

property area
Returns:

float

property dimensions

Copy of the dimensions of the Cuboid3d.

Returns:

Dimensions of the Cuboid3d

Return type:

Vector3d

property position

Copy of the position of the Cuboid3d.

Returns:

Position of the Cuboid3d

Return type:

Vector3d

property rotation

Copy of the rotation of the Cuboid3d.

Returns:

Rotation of the Cuboid3d

Return type:

Vector3d