Skip to content

Commit

Permalink
change to non-keyframe for no-annotation frame
Browse files Browse the repository at this point in the history
Signed-off-by: Shunsuke Miura <[email protected]>
  • Loading branch information
miursh committed Dec 30, 2024
1 parent e106fb1 commit fa360db
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion perception_dataset/deepen/deepen_to_t4_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
)
from perception_dataset.rosbag2.rosbag2_converter import Rosbag2Converter
from perception_dataset.t4_dataset.annotation_files_generator import AnnotationFilesGenerator
from perception_dataset.t4_dataset.keyframe_consistency_resolver import KeyFrameConsistencyResolver
from perception_dataset.t4_dataset.resolver.keyframe_consistency_resolver import KeyFrameConsistencyResolver
from perception_dataset.utils.logger import configure_logger
import perception_dataset.utils.misc as misc_utils

Expand Down
9 changes: 5 additions & 4 deletions perception_dataset/t4_dataset/annotation_files_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ def convert_one_scene(

nusc = NuScenes(version="annotation", dataroot=input_dir, verbose=False)
frame_index_to_sample_token: Dict[int, str] = {}
for frame_index, sample in enumerate(nusc.sample):
frame_index_to_sample_token[frame_index] = sample["token"]
for sample_data in nusc.sample_data:
frame_index = int((sample_data["filename"].split("/")[2]).split(".")[0])
frame_index_to_sample_token[frame_index] = sample_data["sample_token"]
try:
if "LIDAR_TOP" in sample["data"]:
if "LIDAR_TOP" in nusc.sample[0]["data"]:
lidar_sensor_channel = SENSOR_ENUM.LIDAR_TOP.value["channel"]
else:
lidar_sensor_channel = SENSOR_ENUM.LIDAR_CONCAT.value["channel"]
Expand Down Expand Up @@ -118,7 +119,7 @@ def convert_one_scene(
for frame_index_nuim, sample_nuim in enumerate(nuim.sample_data):
if (
sample_nuim["fileformat"] == "png" or sample_nuim["fileformat"] == "jpg"
) and sample_nuim["is_key_frame"]:
):
cam = sample_nuim["filename"].split("/")[1]
cam_idx = self._camera2idx[cam]

Expand Down
11 changes: 8 additions & 3 deletions perception_dataset/t4_dataset/annotation_files_updater.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
from pathlib import Path
import os.path as osp
from typing import Any, Dict
from typing import Any, Dict, List

from perception_dataset.t4_dataset.annotation_files_generator import AnnotationFilesGenerator
from perception_dataset.t4_dataset.classes import (
Expand All @@ -12,6 +13,7 @@
SurfaceAnnTable,
VisibilityTable,
)
from perception_dataset.t4_dataset.resolver.keyframe_consistency_resolver import KeyFrameConsistencyResolver


def _load_json(filepath: str) -> Any:
Expand All @@ -21,8 +23,8 @@ def _load_json(filepath: str) -> Any:


class AnnotationFilesUpdater(AnnotationFilesGenerator):
def __init__(self, with_camera: bool = True, description: Dict[str, Dict[str, str]] = ...):
super().__init__(with_camera, description)
def __init__(self, with_camera: bool = True, description: Dict[str, Dict[str, str]] = ..., surface_categories: List[str] = []):
super().__init__(with_camera, description, surface_categories)
self.description = description

def convert_one_scene(
Expand All @@ -46,6 +48,9 @@ def convert_one_scene(
dataset_name=dataset_name,
)

modifier = KeyFrameConsistencyResolver()
modifier.inspect_and_fix_t4_segment(Path(output_dir))

def _init_table_from_json(self, anno_dir: str) -> None:
self._attribute_table = AttributeTable.from_json(
filepath=osp.join(anno_dir, AttributeTable.FILENAME),
Expand Down

0 comments on commit fa360db

Please sign in to comment.