PointLocation

class PointLocation[source]

Bases: supervisely.io.json.JsonSerializable

PointLocation in (row, col) position. PointLocation object is immutable.

Parameters
row : int or float

Position of PointLocation object on height.

col : int or float

Position of PointLocation object on width.

Usage example
import supervisely as sly

row = 100
col = 200
loc = sly.PointLocation(row, col)

Methods

clone

Makes a copy of the PointLocation object.

fliplr

Flips current PointLocation object in horizontal.

flipud

Flips current PointLocation object in vertical.

from_json

Convert a json dict to PointLocation.

resize

Resize current PointLocation object.

rotate

Rotates current PointLocation object.

scale

Scale current PointLocation.

scale_frow_fcol

Calculates new parameters of PointLocation after scaling in horizontal and vertical.

to_json

Convert the PointLocation to a json dict.

translate

Translate current PointLocation object.

Attributes

col

Position of PointLocation on width.

row

Position of PointLocation on height.

clone()[source]

Makes a copy of the PointLocation object.

Returns

PointLocation object

Return type

PointLocation

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

PointLocation

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

PointLocation

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

PointLocation

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

PointLocation

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

PointLocation

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

PointLocation

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

Scale parameter for height.

fcol : float

Scale parameter for width.

Returns

PointLocation object

Return type

PointLocation

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

dict

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
drow : int

Horizontal shift.

dcol : int

Vertical shift.

Returns

PointLocation object

Return type

PointLocation

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

int

Usage example
print(loc.col)
# Output: 200
property row

Position of PointLocation on height.

Returns

Height of PointLocation

Return type

int

Usage example
print(loc.row)
# Output: 100