raceback (most recent call last):
File "kitti_dataloader.py", line 139, in
dataloader = create_val_dataloader(configs)
File "kitti_dataloader.py", line 54, in create_val_dataloader
multiscale=False, num_samples=configs.num_samples, mosaic=False, random_padding=False)
File "../data_process/kitti_dataset.py", line 59, in __init__
self.sample_id_list = self.remove_invalid_idx(self.image_idx_list)
File "../data_process/kitti_dataset.py", line 183, in remove_invalid_idx
sample_id = int(sample_id)
ValueError: invalid literal for int() with base 10: ''
def show_image_with_boxes(img, objects, calib, show3d=False):
""" Show image with 2D bounding boxes """
img1 = np.copy(img) # for 2d bbox
img2 = np.copy(img) # for 3d bbox
# img3 = np.copy(img) # for 3d bbox
# TODO: change the color of boxes
for obj in objects:
if obj.type == "DontCare":
continue
if obj.type == "Car":
cv2.rectangle(
img1,
(int(obj.xmin), int(obj.ymin)),
(int(obj.xmax), int(obj.ymax)),
(0, 255, 0),
2,
)
if obj.type == "Pedestrian":
cv2.rectangle(
img1,
(int(obj.xmin), int(obj.ymin)),
(int(obj.xmax), int(obj.ymax)),
(255, 255, 0),
2,
)
if obj.type == "Cyclist":
cv2.rectangle(
img1,
(int(obj.xmin), int(obj.ymin)),
(int(obj.xmax), int(obj.ymax)),
(0, 255, 255),
2,
)
box3d_pts_2d, box3d_pts_3d = kitti_data_utils.compute_box_3d(obj, calib.P) # 获得3d框在图像上的投影(8个点,8x2)
if box3d_pts_2d is None:
print("something wrong in the 3D box.")
continue
# 绘制图像上的3d框投影
if obj.type == "Car":
img2 = kitti_data_utils.draw_projected_box3d(img2, box3d_pts_2d, cnf.colors[obj.cls_id])
elif obj.type == "Pedestrian":
img2 = kitti_data_utils.draw_projected_box3d(img2, box3d_pts_2d, cnf.colors[obj.cls_id])
elif obj.type == "Cyclist":
img2 = kitti_data_utils.draw_projected_box3d(img2, box3d_pts_2d, cnf.colors[obj.cls_id])
# project
# box3d_pts_3d_velo = calib.project_rect_to_velo(box3d_pts_3d)
# box3d_pts_32d = utils.box3d_to_rgb_box00(box3d_pts_3d_velo)
# box3d_pts_32d = calib.project_velo_to_image(box3d_pts_3d_velo)
# img3 = utils.draw_projected_box3d(img3, box3d_pts_32d)
# print("img1:", img1.shape)
cv2.imshow("2dbox", img1)
# print("img3:",img3.shape)
# Image.fromarray(img3).show()
if show3d:
# print("img2:",img2.shape)
cv2.imshow("3dbox", img2)
return img2
def show_image_with_boxes(img, objects, calib, show3d=False):
# Show image with 2D bounding boxes
img1 = np.copy(img) # for 2d bbox
img2 = np.copy(img) # for 3d bbox
for obj in objects:
if obj.type == 'DontCare':
continue
cv2.rectangle(img1, (int(obj.xmin),int(obj.ymin)),
(int(obj.xmax),int(obj.ymax)), (0,255,0), 2)
box3d_pts_2d, box3d_pts_3d = kitti_data_utils.compute_box_3d(obj, calib.P)
if box3d_pts_2d is not None:
img2 = kitti_data_utils.draw_projected_box3d(img2, box3d_pts_2d, cnf.colors[obj.cls_id])
if show3d:
cv2.imshow("img", img2)
return img2