Skip to content
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

fix: adjust bbox mask based on frame and sensor #79

Merged
merged 3 commits into from
Feb 20, 2024
Merged
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
8 changes: 5 additions & 3 deletions perception_dataset/t4_dataset/annotation_files_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,12 @@ def _convert_to_t4_format(

# Object Annotation
if "two_d_box" in anno.keys():
anno_two_d_box: List[float] = self._clip_bbox(anno["two_d_box"], mask)
sensor_id: int = int(anno["sensor_id"])
if frame_index not in frame_index_to_sample_data_token[sensor_id]:
continue
anno_two_d_box: List[float] = self._clip_bbox(
anno["two_d_box"], mask[sensor_id][frame_index]
)
self._object_ann_table.insert_into_table(
sample_data_token=frame_index_to_sample_data_token[sensor_id][frame_index],
instance_token=instance_token,
Expand All @@ -292,10 +294,10 @@ def _convert_to_t4_format(
mask=mask[sensor_id][frame_index],
)

def _clip_bbox(self, bbox: List[float], mask: any) -> List[float]:
def _clip_bbox(self, bbox: List[float], mask: Dict[str, Any]) -> List[float]:
"""Clip the bbox to the image size."""
try:
width, height = list(mask[0].values())[0]["size"]
width, height = mask["size"]
bbox[0] = max(0, bbox[0])
bbox[1] = max(0, bbox[1])
bbox[2] = min(width, bbox[2])
Expand Down
Loading