utiasSTARS / pykitti

Python tools for working with KITTI data.
MIT License
1.14k stars 239 forks source link

Code to convert files in kitti tracking to kitti detection #58

Closed sarimmehdi closed 4 years ago

sarimmehdi commented 4 years ago

This is useful if one has to use neural nets, designed for kitti object detection, for the kitti tracking dataset. The kitti tracking dataset has slight changes in the label files and the calib files. The label files in kitti detection have the following format and there is a separate label file for each image:

[name truncated occluded alpha 2dbbox_x1 2d_bbox_y1 2d_bbox_x2 2d_bbox_y2 3d_bbox_height 3d_bbox_width 3d_bbox_length 3d_bbox_x 3d_bbox_y 3d_bbox_z rot_y]

On the other hand, the kitti tracking dataset has only one label file for each folder and the format is:

[frame_num obj_id name truncated occluded alpha 2dbbox_x1 2d_bbox_y1 2d_bbox_x2 2d_bbox_y2 3d_bbox_height 3d_bbox_width 3d_bbox_length 3d_bbox_x 3d_bbox_y 3d_bbox_z rot_y]

Also, there is a difference in the calibration files as well. In the kitti object detection dataset, the calibration files have Tr_velo_to_cam:, Tr_velo_to_imu: and R0_rect: while the kitti tracking dataset has Tr_velo_cam, Tr_velo_imu and R_rect. Furthermore, there is one calib file for each folder of images instead of having a separate calib file for each image as is the case in the kitti detection dataset.

My code takes the files in each image folder in the kitti tracking dataset and converts them to the kitti object detection dataset. So, for example, for training image folder 0000 with 153 images, I take the label file and break it down into 153 label files (one for each image) and I create 153 copies of the calib file (with the necessary changes as well).