PointLocation¶
- class PointLocation[source]¶
Bases:
supervisely.io.json.JsonSerializable
PointLocation in (row, col) position.
PointLocation
object 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.
- clone()[source]¶
Makes a copy of the PointLocation object.
- Returns
PointLocation object
- 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
- img_size : Tuple[int, int]
Input image size (height, width) to which belongs
PointLocation
object.
- Returns
PointLocation object
- 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
- img_size : Tuple[int, int]
Input image size (height, width) to which belongs
PointLocation
object.
- Returns
PointLocation object
- 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))
- classmethod from_json(data)[source]¶
Convert a json dict to PointLocation. Read more about Supervisely format.
- Parameters
- data : dict
PointLocation in json format as a dict.
- Returns
PointLocation object
- Return type
- Usage example
import supervisely as sly loc_json = { "points": { "exterior": [ [ 200, 100 ] ], "interior": [] } } loc = sly.PointLocation.from_json(loc_json)
- resize(in_size, out_size)[source]¶
Resize current PointLocation object.
- Parameters
- in_size : Tuple[int, int]
Input image size (height, width) to which belongs
PointLocation
object.- out_size : Tuple[int, int]
Desired output image size (height, width) to which belongs
PointLocation
object.
- Returns
PointLocation object
- 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 : ImageRotator
ImageRotator object for rotation.
- Returns
PointLocation object
- 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
- factor : float
Scale parameter.
- Returns
PointLocation object
- 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
PointLocation object
- 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
PointLocation object
- 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)
- property col¶
Position of PointLocation on width.
- Returns
Width of PointLocation
- Return type
- Usage example
print(loc.col) # Output: 200