一、KITTI 标注文件格式
在以下网址下载已经标注好的文件,里面有20个场景的标注文件。寻找与自己对应场景的文件。比如我对应的为文档里的0004.txt 。
可以从https://blog.csdn.net/qq_29931083/article/details/106460698 这里下载
通过Tracking里的README可以看到文本记录的格式https://blog.csdn.net/qq_29931083/article/details/106504415
Values Name Description
1 frame Frame within the sequence where the object appearers
1 track id Unique tracking id of this object within this sequence
1 type Describes the type of object: ‘Car’, ‘Van’, ‘Truck’, ‘Pedestrian’, ‘Person_sitting’, ‘Cyclist’, ‘Tram’, ‘Misc’ or ‘DontCare’
1 truncated Integer (0,1,2) indicating the level of truncation.Note that this is in contrast to the object detection benchmark where truncation is a float in [0,1].
1 occluded Integer (0,1,2,3) indicating occlusion state:
0 = fully visible, 1 = partly occluded
2 = largely occluded, 3 = unknown
1 alpha Observation angle of object, ranging [-pi…pi]
4 bbox 2D bounding box of object in the image (0-based index):
contains left, top, right, bottom pixel coordinates
3 dimensions 3D object dimensions: height, width, length (in meters)
3 location 3D object location x,y,z in camera coordinates (in meters)
1 rotation_y Rotation ry around Y-axis in camera coordinates [-pi…pi]
1 score Only for results: Float, indicating confidence in detection, needed for p/r curves, higher is better.
二、画出2D检测框
使用jupyter notebook进行调试,将文件导入查看文件内容:
其中包括了每一帧的帧序号frame;每一个物体特有的id track_id;2D 检测框记录的数据:bbox_lift,bbox_top,bbox_right,bbox_bottom;
import pandas as pd
Columns_name = ['frame','track_id','type','truncated','occluded','alpha','bbox_lift','bbox_top','bbox_right','bbox_bottom','height','width','length','pos_x','pos_y','pos_z','rot_y']
df = pd.read_csv('/home/liqi/dev/catkin_ws/src/KITTI_tutorials/2011_09_26_drive_0014_sync/training/label_02/0004.txt',header = None,sep = ' ')
df.columns = Columns_name
df.head()
其中的frame与资料集中的文件相对应,如第0帧 即frame 为0时,可对应下图有4辆car和一辆Van。
为了后续的方便 将 type 中的’Van’,‘Truck’,‘Tram’ 都转为 Car,使用以下语句,首先使用df.type.isin() 定位出’Van’,‘Truck’,‘Tram’ 是否在type中;显示为True的通过df.loc[ ,’type’] =’Car’ 定位 并将其中的的type类型改为Car
df.loc[df.type.isin(['Van','Truck','Tram']),'type']='Car'
修改完成以后类别中只剩下 ‘Car’,‘Cyclist’,‘Pedestrian’ 和 DontCare Misc 等类别,为了简化数据只保留type为 ‘Car’,‘Cyclist’,‘Pedestrian’ 的数