Point

class Point(row, col, sly_id=None, class_id=None, labeler_login=None, updated_at=None, created_at=None)[source]

Bases: Geometry

2D point at (row, col). Immutable.

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

Returns the allowed transforms for the Point.

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

Crops current Point.

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

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

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

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

Validate geometry.

Attributes

area

Point area.

col

Position of Point width.

point_location

Get PointLocation from Point.

row

Position of Point height.

classmethod allowed_transforms()[source]

Returns the allowed transforms for the Point.

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 from json.

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 to create Point from.

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)
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

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

Crops current Point.

Parameters:
rect

Rectangle to crop Point from.

Returns:

List of Points from Rectangle.

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

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

Flips current Point in horizontal.

Parameters:
img_size : Tuple[int, int]

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

Returns:

Flipped Point.

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.

Returns:

Flipped Point.

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

Resizes current Point.

Parameters:
in_size : Tuple[int, int]

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:

Resized Point.

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

Class for object rotation.

Returns:

Rotated Point.

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:

Scaled Point.

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 from Point.

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:

Point in 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:

Translated Point.

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)
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 : float

Point area.

Returns:

Area of current Point, always 0.0

Return type:

float

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

Position of Point width.

Returns:

Width of Point.

Return type:

int

Usage Example:
print(figure.col)
# Output: 200
property point_location : supervisely.geometry.point_location.PointLocation

Get PointLocation from Point.

Returns:

PointLocation from Point.

Return type:

PointLocation

Usage Example:
figure_loc = figure.point_location
property row : int

Position of Point height.

Returns:

Height of Point.

Return type:

int

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