tensorbay.geometry.keypoint¶
Keypoints2D, Keypoint2D.
Keypoint2D
contains the information of 2D keypoint,
such as the coordinates and visible status(optional).
Keypoints2D
contains a list of 2D keypoint and is based on
PointList2D
.
- class tensorbay.geometry.keypoint.Keypoint2D(*args: float, **kwargs: float)[source]¶
Bases:
tensorbay.utility.user.UserSequence
[float
]This class defines the concept of Keypoint2D.
Keypoint2D
contains the information of 2D keypoint, such as the coordinates and visible status(optional).- Parameters
x – The x coordinate of the 2D keypoint.
y – The y coordinate of the 2D keypoint.
v –
The visible status(optional) of the 2D keypoint.
Visible status can be “BINARY” or “TERNARY”:
Visual Status
v = 0
v = 1
v = 2
BINARY
visible
invisible
TERNARY
visible
occluded
invisible
Examples
Initialization Method 1: Init from coordinates of x, y.
>>> Keypoint2D(1.0, 2.0) Keypoint2D(1.0, 2.0)
Initialization Method 2: Init from coordinates and visible status.
>>> Keypoint2D(1.0, 2.0, 0) Keypoint2D(1.0, 2.0, 0)
- classmethod loads(contents: Dict[str, float]) tensorbay.geometry.keypoint._T [source]¶
Load a
Keypoint2D
from a dict containing coordinates of a 2D keypoint.- Parameters
contents – A dict containing coordinates and visible status(optional) of a 2D keypoint.
- Returns
The loaded
Keypoint2D
object.
Examples
>>> contents = {"x":1.0,"y":2.0,"v":1} >>> Keypoint2D.loads(contents) Keypoint2D(1.0, 2.0, 1)
- property v: Optional[int]¶
Return the visible status of the 2D keypoint.
- Returns
Visible status of the 2D keypoint.
Examples
>>> keypoint = Keypoint2D(3.0, 2.0, 1) >>> keypoint.v 1
- dumps() Dict[str, float] [source]¶
Dumps the
Keypoint2D
into a dict.- Returns
A dict containing coordinates and visible status(optional) of the 2D keypoint.
Examples
>>> keypoint = Keypoint2D(1.0, 2.0, 1) >>> keypoint.dumps() {'x': 1.0, 'y': 2.0, 'v': 1}
- class tensorbay.geometry.keypoint.Keypoints2D(points: Optional[Iterable[Iterable[float]]] = None)[source]¶
Bases:
tensorbay.geometry.point_list.PointList2D
[tensorbay.geometry.keypoint.Keypoint2D
]This class defines the concept of Keypoints2D.
Keypoints2D
contains a list of 2D keypoint and is based onPointList2D
.Examples
>>> Keypoints2D([[1, 2], [2, 3]]) Keypoints2D [ Keypoint2D(1, 2), Keypoint2D(2, 3) ]
- classmethod loads(contents: List[Dict[str, float]]) tensorbay.geometry.keypoint._P [source]¶
Load a
Keypoints2D
from a list of dict.- Parameters
contents – A list of dictionaries containing 2D keypoint.
- Returns
The loaded
Keypoints2D
object.
Examples
>>> contents = [{"x": 1.0, "y": 1.0, "v": 1}, {"x": 2.0, "y": 2.0, "v": 2}] >>> Keypoints2D.loads(contents) Keypoints2D [ Keypoint2D(1.0, 1.0, 1), Keypoint2D(2.0, 2.0, 2) ]