|
5 | 5 | from typing import Dict, List, Optional, Sequence, Type, Union |
6 | 6 | from urllib.parse import urlparse |
7 | 7 |
|
| 8 | +import numpy as np |
| 9 | + |
8 | 10 | from .constants import ( |
9 | 11 | ANNOTATION_ID_KEY, |
10 | 12 | ANNOTATIONS_KEY, |
|
15 | 17 | EMBEDDING_VECTOR_KEY, |
16 | 18 | GEOMETRY_KEY, |
17 | 19 | HEIGHT_KEY, |
| 20 | + I_KEY, |
18 | 21 | INDEX_KEY, |
19 | 22 | KEYPOINTS_KEY, |
20 | 23 | KEYPOINTS_NAMES_KEY, |
@@ -588,6 +591,38 @@ def from_json(cls, payload: Dict[str, float]): |
588 | 591 | def to_payload(self) -> dict: |
589 | 592 | return {X_KEY: self.x, Y_KEY: self.y, Z_KEY: self.z} |
590 | 593 |
|
| 594 | + def to_list(self): |
| 595 | + return [self.x, self.y, self.z] |
| 596 | + |
| 597 | + |
| 598 | +@dataclass |
| 599 | +class LidarPoint(Point3D): |
| 600 | + """A Lidar point in 3D space and intensity. |
| 601 | +
|
| 602 | + Parameters: |
| 603 | + x (float): The x coordinate of the point. |
| 604 | + y (float): The y coordinate of the point. |
| 605 | + z (float): The z coordinate of the point. |
| 606 | + i (float): The intensity value returned by the lidar scan point. |
| 607 | + """ |
| 608 | + |
| 609 | + i: float |
| 610 | + |
| 611 | + @classmethod |
| 612 | + def from_json(cls, payload: Dict[str, float]): |
| 613 | + return cls( |
| 614 | + payload[X_KEY], payload[Y_KEY], payload[Z_KEY], payload[I_KEY] |
| 615 | + ) |
| 616 | + |
| 617 | + def to_payload(self) -> dict: |
| 618 | + return {X_KEY: self.x, Y_KEY: self.y, Z_KEY: self.z, I_KEY: self.i} |
| 619 | + |
| 620 | + def to_list(self): |
| 621 | + return [self.x, self.y, self.z, self.i] |
| 622 | + |
| 623 | + def to_numpy(self): |
| 624 | + return np.array(self.to_list()) |
| 625 | + |
591 | 626 |
|
592 | 627 | @dataclass # pylint: disable=R0902 |
593 | 628 | class CuboidAnnotation(Annotation): # pylint: disable=R0902 |
|
0 commit comments