Exemple #1
0
def test_read_dataset():
    print("===== start test_read_dataset")
    dataset = TfrecordReader(op.join(cfg.Paths.TFRECORD,
                                     "kitti_train")).get_dataset()
    for i, x in enumerate(dataset):
        print(
            f"=== index: {i}, image={x['image'].shape}, bbox={x['bboxes'].shape}"
            f", feature_l={x['feature_l'].shape}, feature_s={x['feature_s'].shape}"
        )
        image = uf.to_uint8_image(x['image'])
        image = image[0].numpy()
        bboxes = x['bboxes'][0].numpy()
        image = tu.draw_boxes(image, bboxes, cfg.Tfrdata.CATEGORY_NAMES)
        cv2.imshow("image with boxes", image)

        features = []
        for feat_name in cfg.Model.Output.FEATURE_ORDER:
            feature = x[feat_name][0].numpy()
            feature = feature[feature[..., 4] > 0]
            features.append(feature)
        feat_boxes = np.concatenate(features, axis=0)
        image = tu.draw_boxes(image, feat_boxes, cfg.Tfrdata.CATEGORY_NAMES)
        cv2.imshow("image with feature bboxes", image)
        key = cv2.waitKey()
        if key == ord('q'):
            break

    print("!!! test_read_dataset passed")
Exemple #2
0
    def show_example(self, example):
        category_names = cfg.Tfrdata.CATEGORY_NAMES
        image = tu.draw_boxes(example["image"], example["bboxes"], category_names)
        cv2.imshow("image with bboxes", image)

        features = []
        for feat_name in cfg.Model.FEATURE_ORDER:
            feature = example[feat_name]
            feature = feature[feature[..., 4] > 0]      # objectness == 1
            features.append(feature)
        feat_boxes = np.concatenate(features, axis=0)
        image = tu.draw_boxes(example["image"], feat_boxes, category_names)
        cv2.imshow("image with feature bboxes", image)
        cv2.waitKey(100)
Exemple #3
0
def test_kitti_reader():
    print("===== start test_kitti_reader")
    dataset_cfg = cfg.Datasets.Kitti
    drive_mngr = KittiDriveManager(dataset_cfg.PATH, "train")
    drive_paths = drive_mngr.get_drive_paths()
    reader = KittiReader(drive_paths[0], "train", dataset_cfg)
    for i in range(reader.num_frames()):
        image = reader.get_image(i)
        bboxes = reader.get_bboxes(i)
        print(f"frame {i}, bboxes:\n", bboxes)
        boxed_image = tu.draw_boxes(image, bboxes, dataset_cfg.CATEGORIES_TO_USE)
        cv2.imshow("kitti", boxed_image)
        key = cv2.waitKey()
        if key == ord('q'):
            break
    print("!!! test_kitti_reader passed")