Point¶
-
class Point(row, col, sly_id=
None, class_id=None, labeler_login=None, updated_at=None, created_at=None)[source]¶ Bases:
Geometry2D point at (row, col). Immutable.
Point geometry for a single
Label.Pointobject 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
Returns the allowed transforms for the Point.
Clone from GEOMETRYYY
Convert geometry config from json format
Convert geometry config to json format
Convert geometry to another geometry shape.
Crops current Point.
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.
Flips current Point in horizontal.
Flips current Point in vertical.
Convert a json dict to Point.
Create Point from given
PointLocationobject.geometry_nameReturns 2D boolean mask of the geometry.
Get the name of the geometry.
Crops object like "crop" method, but return results with coordinates relative to rect :param rect: Rectangle for crop.
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 geometry.
Attributes
Point area.
Position of Point width.
Get PointLocation from Point.
Position of Point height.
- 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
PointLocationobject.- 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:
Pointobject- Return type:
- 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
- clone()¶
Clone from GEOMETRYYY
-
convert(new_geometry, contour_radius=
0, approx_epsilon=None)¶ Convert geometry to another geometry shape.
-
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:
Flipped Point.
- 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:
Flipped Point.
- 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))
- 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
- 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:
- Returns:
Resized Point.
- 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¶
Class for object rotation.
- Returns:
Rotated Point.
- 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 from Point.
- Return type:
- 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:
- Usage Example:
figure_json = figure.to_json() print(figure_json) # Output: { # "points": { # "exterior": [ # [200, 100] # ], # "interior": [] # } # }
- validate(obj_class_shape, settings)¶
Validate geometry.
- Parameters:
- Raises:
ValueError – if geometry validation error
- property area : float¶
Point area.
- Returns:
Area of current Point, always 0.0
- Return type:
- Usage Example:
print(figure.area) # Output: 0.0
- property col : int¶
Position of Point width.
- Returns:
Width of Point.
- Return type:
- 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:
- Usage Example:
figure_loc = figure.point_location