Point

class Point[source]

Bases: supervisely.geometry.geometry.Geometry

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

Parameters
row : int or float

Position of Point on height.

col : int or float

Position of Point on width.

sly_id : int, optional

Point ID in Supervisely server.

class_id : int, optional

ID of ObjClass to which Point belongs.

labeler_login : str, optional

Login of the user who created Point.

updated_at : str, optional

Date and Time when Point 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 Point was created. Date Format is the same as in “updated_at” parameter.

Usage example
import supervisely as sly

row = 100
col = 200
figure = sly.Point(row, col)

Methods

allowed_transforms

clone

Clone from GEOMETRYYY

config_from_json

config_to_json

convert

crop

Crops current Point.

draw

param bitmap

np.ndarray

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.

fliplr

Flips current Point in horizontal.

flipud

Flips current Point in vertical.

from_json

Convert a json dict to Point.

from_point_location

Create Point from given PointLocation object.

geometry_name

get_mask

Returns 2D boolean mask of the geometry.

name

Same as geometry_name(), but shorter.

relative_crop

Crops object like "crop" method, but return results with coordinates relative to rect :param rect: :return: list of Geometry

resize

Resizes current Point.

rotate

Rotates current Point.

scale

Scales current Point.

to_bbox

Create Rectangle object from current Point.

to_json

Convert the Point to a json dict.

translate

Translates current Point.

validate

Attributes

area

Point area.

col

Position of Point width.

point_location

Create PointLocation object from Point.

row

Position of Point height.

classmethod allowed_transforms()[source]
clone()

Clone from GEOMETRYYY

crop(rect)[source]

Crops current Point.

Parameters
rect : Rectangle

Rectangle object for crop.

Returns

List of Point objects

Return type

List[Point]

Usage Example
import supervisely as sly

crop_figures = figure.crop(sly.Rectangle(1, 1, 300, 350))
draw(bitmap, color, thickness=1, config=None)
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)

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)[source]

Flips current Point in horizontal.

Parameters
img_size : Tuple[int, int]

Input image size (height, width) to which belongs Point object.

Returns

Point object

Return type

Point

Usage Example
# Remember that Point class object is immutable, and we need to assign new instance of Point to a new variable
height, width = 300, 400
fliplr_figure = figure.fliplr((height, width))
flipud(img_size)[source]

Flips current Point in vertical.

Parameters
img_size : Tuple[int, int]

Input image size (height, width) to which belongs Point object.

Returns

Point object

Return type

Point

Usage Example
# Remember that Point class object is immutable, and we need to assign new instance of Point to a new variable
height, width = 300, 400
flipud_figure = figure.flipud((height, width))
classmethod from_json(data)[source]

Convert a json dict to Point. Read more about Supervisely format.

Parameters
data : dict

Point in json format as a dict.

Returns

Point object

Return type

Point

Usage example
import supervisely as sly

figure_json = {
    "points": {
        "exterior": [
            [200, 100]
        ],
        "interior": []
    }
}
figure = sly.Point.from_json(figure_json)
classmethod from_point_location(pt, sly_id=None, class_id=None, labeler_login=None, updated_at=None, created_at=None)[source]

Create Point from given PointLocation object.

Parameters
pt : PointLocation

PointLocation object.

sly_id : int, optional

Point ID in Supervisely server.

class_id : int, optional

ID of ObjClass to which Point belongs.

labeler_login : str, optional

Login of the user who created Point.

updated_at : str, optional

Date and Time when Point 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 Point was created. Date Format is the same as in “updated_at” parameter.

Returns

Point object

Return type

Point

Usage example
import supervisely as sly

figure_loc = sly.PointLocation(100, 200)
figure = sly.Point.from_point_location(figure_loc)
static geometry_name()[source]
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

classmethod name()

Same as geometry_name(), but shorter. In order to make the code more concise.

Returns

string with name of geometry

relative_crop(rect)

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]

Resizes current Point.

Parameters
in_size : Tuple[int, int]

Input Input image size (height, width) to which belongs Point.

out_size : Tuple[int, int]

Desired output image size (height, width) to which belongs Point.

Returns

Point object

Return type

Point

Usage Example
# Remember that Point class object is immutable, and we need to assign new instance of Point to a new variable
in_height, in_width = 300, 400
out_height, out_width = 600, 800
resize_figure = figure.resize((in_height, in_width), (out_height, out_width))
rotate(rotator)[source]

Rotates current Point.

Parameters
rotator : ImageRotator

ImageRotator object for rotation.

Returns

Point object

Return type

Point

Usage Example
import supervisely as sly
from supervisely.geometry.image_rotator import ImageRotator

# Remember that Point class object is immutable, and we need to assign new instance of Point to a new variable
height, width = 300, 400
rotator = ImageRotator((height, width), 25)
rotate_figure = figure.rotate(rotator)
scale(factor)[source]

Scales current Point.

Parameters
factor : float

Scale parameter.

Returns

Point object

Return type

Point

Usage Example
# Remember that Point class object is immutable, and we need to assign new instance of Point to a new variable
scale_figure = figure.scale(0.75)
to_bbox()[source]

Create Rectangle object from current Point.

Returns

Rectangle object

Return type

Rectangle

Usage Example
rectangle = figure.to_bbox()
to_json()[source]

Convert the Point to a json dict. Read more about Supervisely format.

Returns

Json format as a dict

Return type

dict

Usage example
figure_json = figure.to_json()
print(figure_json)
# Output: {
#    "points": {
#        "exterior": [
#            [200, 100]
#        ],
#        "interior": []
#    }
# }
translate(drow, dcol)[source]

Translates current Point.

Parameters
drow : int

Horizontal shift.

dcol : int

Vertical shift.

Returns

Point object

Return type

Point

Usage Example
# Remember that Point class object is immutable, and we need to assign new instance of Point to a new variable
translate_figure = figure.translate(150, 350)
property area

Point area.

Returns

Area of current Point object, always 0.0

Return type

float

Usage Example
print(figure.area)
# Output: 0.0
property col

Position of Point width.

Returns

Width of Point

Return type

int

Usage example
print(figure.col)
# Output: 200
property point_location

Create PointLocation object from Point.

Returns

PointLocation object

Return type

PointLocation

Usage example
figure_loc = figure.point_location
property row

Position of Point height.

Returns

Height of Point

Return type

int

Usage example
print(figure.row)
# Output: 100