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
Clone from GEOMETRYYY
config_from_json
config_to_json
convert
Crops current Point.
- 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.
Flips current Point in horizontal.
Flips current Point in vertical.
Convert a json dict to Point.
Create Point from given
PointLocation
object.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
Resizes current Point.
Rotates current Point.
Scales current Point.
Create Rectangle object from current Point.
Convert the Point to a json dict.
Translates current Point.
validate
Attributes
Point area.
Position of Point width.
Create PointLocation object from Point.
Position of Point height.
- clone()¶
Clone from GEOMETRYYY
- crop(rect)[source]¶
Crops current Point.
- Parameters
- rect : Rectangle
Rectangle object for crop.
- Returns
List of Point objects
- Return type
- 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
- Returns
Point object
- Return type
- 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
- Returns
Point object
- Return type
- 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.
-
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
- Usage example
import supervisely as sly figure_loc = sly.PointLocation(100, 200) figure = sly.Point.from_point_location(figure_loc)
- 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
- 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
- Returns
Point object
- Return type
- 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
- 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)
- to_bbox()[source]¶
Create Rectangle object from current Point.
- Returns
Rectangle object
- Return type
- 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
- Usage example
figure_json = figure.to_json() print(figure_json) # Output: { # "points": { # "exterior": [ # [200, 100] # ], # "interior": [] # } # }
- property area¶
Point area.
- Returns
Area of current Point object, always 0.0
- Return type
- Usage Example
print(figure.area) # Output: 0.0
- property col¶
Position of Point width.
- Returns
Width of Point
- Return type
- Usage example
print(figure.col) # Output: 200
- property point_location¶
Create PointLocation object from Point.
- Returns
PointLocation object
- Return type
- Usage example
figure_loc = figure.point_location