MotionNet SourceCode 解读[#2]-gen_data篇(part II)

这篇文章要继续解读 MotionNet 中 gen_data的第二部份。

for ann_token in corresponding_sample_rec['anns']:    #取得一个instance的annotation_record    ann_rec = nusc.get('sample_annotation', ann_token)    #print(ann_rec)    category_name = ann_rec['category_name']    instance_token = ann_rec['instance_token']        # 把文字的类别 转换成数字代表 如果不存在一开始预设的类别则设定为Other类别 = 4    flag = False    for c, v in class_map.items():        if category_name.startswith(c):            box_data_dict['category_' + instance_token] = v            flag = True            break    if not flag:        box_data_dict['category_' + instance_token] = 4  # Other category    #取得当下这个instsance的过去几个sweep跟未来的几个bounding box 资讯 还有每个sweep对应到的timestamp    instance_boxes, instance_all_times, _, _ = LidarPointCloud. \        get_instance_boxes_multisweep_sample_data(nusc, curr_sample_data,                                                  instance_token,                                                  nsweeps_back=nsweeps_back,                                                  nsweeps_forward=nsweeps_forward)    assert np.array_equal(unique_times, instance_all_times), "The sweep and instance times are inconsistent!"    assert num_sweeps == len(instance_boxes), "The number of instance boxes does not match that of sweeps!"    # Each row corresponds to a box annotation; the column consists of box center, box size, and quaternion    # 这边把bounding box的资讯都记录下来     box_data = np.zeros((len(instance_boxes), 3 + 3 + 4), dtype=np.float32)    box_data.fill(np.nan)    for r, box in enumerate(instance_boxes):        if box is not None:            row = np.concatenate([box.center, box.wlh, box.orientation.elements])            box_data[r] = row[:]        # 这边的话把box_data存进box_data_dict对应的instance_token下 会是(total sweeps,10)的格式    # Save the box data for current instance    box_data_dict['instance_boxes_' + instance_token] = box_data    num_instances += 1        curr_token_list.append(instance_token)    #把所有instance_token都存进一个list中    save_data_dict['num_instances'] = num_instancessave_data_dict_list.append(save_data_dict)save_box_dict_list.append(box_data_dict)save_instance_token_list.append(curr_token_list)#把对应的资料存进dict中

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章