Skip to content

added token field to Box class #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions python-sdk/nuscenes/nuscenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ def get_box(self, sample_annotation_token: str) -> Box:
:param sample_annotation_token: Unique sample_annotation identifier.
"""
record = self.get('sample_annotation', sample_annotation_token)
return Box(record['translation'], record['size'], Quaternion(record['rotation']), name=record['category_name'])
return Box(record['translation'], record['size'], Quaternion(record['rotation']),
name=record['category_name'], token=record['token'])

def get_boxes(self, sample_data_token: str) -> List[Box]:
"""
Expand Down Expand Up @@ -309,7 +310,8 @@ def get_boxes(self, sample_data_token: str) -> List[Box]:
q1=Quaternion(curr_ann_rec['rotation']),
amount=(t - t0) / (t1 - t0))

box = Box(center, curr_ann_rec['size'], rotation, name=curr_ann_rec['category_name'])
box = Box(center, curr_ann_rec['size'], rotation, name=curr_ann_rec['category_name'],
token=curr_ann_rec['token'])
else:
# If not, simply grab the current annotation.
box = self.get_box(curr_ann_rec['token'])
Expand Down
9 changes: 6 additions & 3 deletions python-sdk/nuscenes/utils/data_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ def __init__(self,
label: int = np.nan,
score: float = np.nan,
velocity: Tuple = (np.nan, np.nan, np.nan),
name: str = None):
name: str = None,
token: str = None):
"""
:param center: Center of box given as x, y, z.
:param size: Size of box in width, length, height.
Expand All @@ -452,6 +453,7 @@ def __init__(self,
:param score: Classification score, optional.
:param velocity: Box velocity in x, y, z direction.
:param name: Box name, optional. Can be used e.g. for denote category name.
:param token: Unique string identifier from DB.
"""
assert not np.any(np.isnan(center))
assert not np.any(np.isnan(size))
Expand All @@ -466,6 +468,7 @@ def __init__(self,
self.score = float(score) if not np.isnan(score) else score
self.velocity = np.array(velocity)
self.name = name
self.token = token

def __eq__(self, other):
center = np.allclose(self.center, other.center)
Expand All @@ -481,12 +484,12 @@ def __eq__(self, other):
def __repr__(self):
repr_str = 'label: {}, score: {:.2f}, xyz: [{:.2f}, {:.2f}, {:.2f}], wlh: [{:.2f}, {:.2f}, {:.2f}], ' \
'rot axis: [{:.2f}, {:.2f}, {:.2f}], ang(degrees): {:.2f}, ang(rad): {:.2f}, ' \
'vel: {:.2f}, {:.2f}, {:.2f}, name: {}'
'vel: {:.2f}, {:.2f}, {:.2f}, name: {}, token: {}'

return repr_str.format(self.label, self.score, self.center[0], self.center[1], self.center[2], self.wlh[0],
self.wlh[1], self.wlh[2], self.orientation.axis[0], self.orientation.axis[1],
self.orientation.axis[2], self.orientation.degrees, self.orientation.radians,
self.velocity[0], self.velocity[1], self.velocity[2], self.name)
self.velocity[0], self.velocity[1], self.velocity[2], self.name, self.token)

@property
def rotation_matrix(self) -> np.ndarray:
Expand Down