otx.api.entities.shapes.shape#

This file defines the ShapeEntity interface and the Shape abstract class.

Classes

Shape(shape_type, modification_date)

Base class for Shape entities.

ShapeEntity(shape_type)

This interface represents the annotation shapes on the media given by user annotations or system analysis.

ShapeType(value)

Shows which type of Shape is being used.

Exceptions

GeometryException

Exception that is thrown if the geometry of a Shape is invalid.

exception otx.api.entities.shapes.shape.GeometryException[source]#

Bases: ValueError

Exception that is thrown if the geometry of a Shape is invalid.

class otx.api.entities.shapes.shape.Shape(shape_type: ShapeType, modification_date: datetime)[source]#

Bases: ShapeEntity

Base class for Shape entities.

contains_center(other: ShapeEntity) bool[source]#

Checks whether the center of the ‘other’ shape is located in the shape.

Parameters:

other (ShapeEntity) – Shape to compare with.

Returns:

Boolean that indicates whether the center of the other shape is located in the shape

Return type:

bool

get_area() float[source]#

Get the area of the shape.

intersects(other: Shape) bool[source]#

Returns True, if other intersects with shape, otherwise returns False.

class otx.api.entities.shapes.shape.ShapeEntity(shape_type: ShapeType)[source]#

Bases: object

This interface represents the annotation shapes on the media given by user annotations or system analysis.

The shapes is a 2D geometric shape living in a normalized coordinate system (the values range from 0 to 1).

abstract contains_center(other: ShapeEntity) bool[source]#

Checks whether the center of the ‘other’ shape is located in the shape.

Parameters:

other (ShapeEntity) – Shape to compare with

Returns:

true if the center of the ‘other’ shape is located in the shape, otherwise returns false

Return type:

bool

abstract denormalize_wrt_roi_shape(roi_shape: Rectangle) ShapeEntity[source]#

The inverse of normalize_wrt_roi_shape.

Transforming shape from the normalized coordinate system to the roi coordinate system. This is used to pull ground truth during training process of the tasks. Examples given in the Shape implementations.

Parameters:

roi_shape (Rectangle) – Shape of the roi.

Returns:

Shape in the roi coordinate system.

Return type:

ShapeEntity

abstract get_area() float[source]#

Get the area of the shape.

abstract intersects(other: Shape) bool[source]#

Returns true if other intersects with shape, otherwise returns false.

Parameters:

other (Shape) – Shape to compare with

Returns:

true if other intersects with shape, otherwise returns false

Return type:

bool

abstract normalize_wrt_roi_shape(roi_shape: Rectangle) Shape[source]#

The inverse of denormalize_wrt_roi_shape.

Transforming shape from the roi coordinate system to the normalized coordinate system. This is used when the tasks want to save the analysis results.

For example in Detection -> Segmentation pipeline, the analysis results of segmentation needs to be normalized to the roi (bounding boxes) coming from the detection.

Parameters:

roi_shape (Rectangle) – Shape of the roi.

Returns:

Shape in the normalized coordinate system.

Return type:

Shape

property type: ShapeType#

Get the type of Shape that this Shape represents.

class otx.api.entities.shapes.shape.ShapeType(value)[source]#

Bases: IntEnum

Shows which type of Shape is being used.