Vertical-Beach / ai-edge-contest6

The implementation of the 6th AI Edge Contest on SIGNATE of team Vertical-Beach.
0 stars 0 forks source link

データセットの可視化 #3

Closed lp6m closed 2 years ago

lp6m commented 2 years ago

nuScenesデータセットと同じフォーマットになっているので、nuscens-devkitを使用して可視化他を行うことができる。

https://www.nuscenes.org/nuscenes?tutorial=nuscenes


import os
import cv2
from nuscenes.nuscenes import NuScenes

def hconcat_resize_max(im_list, interpolation=cv2.INTER_CUBIC):
    h_max = max(im.shape[0] for im in im_list)
    im_list_resize = [cv2.resize(im, (int(im.shape[1] * h_max / im.shape[0]), h_max), interpolation=interpolation)
                      for im in im_list]
    return cv2.hconcat(im_list_resize)

OUTPUT_DIR = "./visualized"
os.makedirs(OUTPUT_DIR, exist_ok=True)

nusc = NuScenes(version='v1.0-trainval', dataroot='/media/lp6m/HDD6TB/aiedge6/materials/train/3d_labels', verbose=True)

for scene in nusc.scene:
    current_sample_token = scene['first_sample_token']
    while not current_sample_token == '':
        sample = nusc.get('sample', current_sample_token)
        cam_front_data = nusc.get('sample_data', sample['data']['CAM_FRONT'])
        cam_img_filename = os.path.basename(cam_front_data['filename'])
        # render camera front image
        nusc.render_sample_data(cam_front_data['token'], out_path="tmp.jpg")
        img1 = cv2.imread("tmp.jpg")
        # render lidar point data
        nusc.render_sample_data(sample['data']['LIDAR_TOP'], underlay_map=True, out_path="tmp2.jpg")
        img2 = cv2.imread("tmp2.jpg")

        concat_img = hconcat_resize_max([img1, img2])
        cv2.imwrite(os.path.join(OUTPUT_DIR, cam_img_filename), concat_img)

        current_sample_token = sample['next']

TAUhWTHxtUtDLbEKrAvtmAn6_14 HavlOgYpwQNuWPnzpPti53w5_136

ほとんどのデータが前方にしかアノテーションデータがない・・・