PointLocation¶
- class PointLocation(row, col)[source]¶
Bases:
JsonSerializable2D pixel coordinate (row, col); used for point positions and polygon vertices. Immutable.
PointLocation in (row, col) position.
PointLocationobject is immutable.- Parameters:
- Usage Example:
import supervisely as sly row = 100 col = 200 loc = sly.PointLocation(row, col)
Methods
Makes a copy of the PointLocation object.
Flips current PointLocation object in horizontal.
Flips current PointLocation object in vertical.
Convert a json dict to PointLocation.
Resize current PointLocation object.
Rotates current PointLocation object.
Scale current PointLocation.
Calculates new parameters of PointLocation after scaling in horizontal and vertical.
Convert the PointLocation to a json dict.
Translate current PointLocation object.
Attributes
Position of PointLocation on width.
Position of PointLocation on height.
- classmethod from_json(data)[source]¶
Convert a json dict to PointLocation. Read more about Supervisely format.
- Parameters:
- Returns:
PointLocation from json.
- Return type:
- Usage Example:
import supervisely as sly loc_json = { "points": { "exterior": [ [ 200, 100 ] ], "interior": [] } } loc = sly.PointLocation.from_json(loc_json)
- clone()[source]¶
Makes a copy of the PointLocation object.
- Returns:
Copied PointLocation.
- Return type:
- Usage Example:
# Remember that PointLocation class object is immutable, and we need to assign new instance of PointLocation to a new variable new_loc = loc.clone()
- fliplr(img_size)[source]¶
Flips current PointLocation object in horizontal.
- Parameters:
- Returns:
Flipped PointLocation.
- Return type:
- Usage Example:
# Remember that PointLocation class object is immutable, and we need to assign new instance of PointLocation to a new variable height, width = 300, 400 fliplr_loc = loc.fliplr((height, width))
- flipud(img_size)[source]¶
Flips current PointLocation object in vertical.
- Parameters:
- Returns:
Flipped PointLocation.
- Return type:
- Usage Example:
# Remember that PointLocation class object is immutable, and we need to assign new instance of PointLocation to a new variable height, width = 300, 400 flipud_loc = loc.flipud((height, width))
- resize(in_size, out_size)[source]¶
Resize current PointLocation object.
- Parameters:
- Returns:
Resized PointLocation.
- Return type:
- Usage Example:
# Remember that PointLocation class object is immutable, and we need to assign new instance of PointLocation to a new variable in_height, in_width = 300, 400 out_height, out_width = 600, 800 resize_loc = loc.resize((in_height, in_width), (out_height, out_width))
- rotate(rotator)[source]¶
Rotates current PointLocation object.
- Parameters:
- rotator¶
Class for object rotation.
- Returns:
Rotated PointLocation.
- Return type:
- Usage Example:
from supervisely.geometry.image_rotator import ImageRotator # Remember that PointLocation class object is immutable, and we need to assign new instance of PointLocation to a new variable height, width = 300, 400 rotator = ImageRotator((height, width), 25) rotate_loc = loc.rotate(rotator)
- scale(factor)[source]¶
Scale current PointLocation.
- Parameters:
- Returns:
Scaled PointLocation.
- Return type:
- Usage Example:
# Remember that PointLocation class object is immutable, and we need to assign new instance of PointLocation to a new variable scale_loc = loc.scale(0.75)
- scale_frow_fcol(frow, fcol)[source]¶
Calculates new parameters of PointLocation after scaling in horizontal and vertical.
- Parameters:
- Returns:
Scaled PointLocation.
- Return type:
- Usage Example:
# Remember that PointLocation class object is immutable, and we need to assign new instance of PointLocation to a new variable loc_scale_rc = loc.scale_frow_fcol(0.1, 2.7)
- to_json()[source]¶
Convert the PointLocation to a json dict. Read more about Supervisely format.
- Returns:
Json format as a dict
- Return type:
- Usage Example:
loc_json = loc.to_json() print(loc_json) # Output: { # "points": { # "exterior": [ # [ # 200, # 100 # ] # ], # "interior": [] # } # }
- translate(drow, dcol)[source]¶
Translate current PointLocation object.
- Parameters:
- Returns:
Translated PointLocation.
- Return type:
- Usage Example:
# Remember that PointLocation class object is immutable, and we need to assign new instance of PointLocation to a new variable translate_loc = loc.translate(150, 350)