Exemplo n.º 1
0
    def test_raises_error_when_seconds_negative(self):
        mock_samples = [{'token': '1', 'timestamp': 0, 'anns': ['1', '1b']}]
        nusc = MockNuScenes(self.mock_annotations, mock_samples)
        helper = PredictHelper(nusc)
        with self.assertRaises(ValueError):
            helper.get_future_for_agent('1', '1', -1, False)

        with self.assertRaises(ValueError):
            helper.get_past_for_agent('1', '1', -1, False)

        with self.assertRaises(ValueError):
            helper.get_past_for_sample('1', -1, False)

        with self.assertRaises(ValueError):
            helper.get_future_for_sample('1', -1, False)
Exemplo n.º 2
0
    def test_get_past_for_sample(self):

        mock_samples = [{
            'token': '5',
            'timestamp': 0,
            'anns': ['5', '5b']
        }, {
            'token': '4',
            'timestamp': -1e6
        }, {
            'token': '3',
            'timestamp': -2e6
        }, {
            'token': '2',
            'timestamp': -3e6
        }, {
            'token': '1',
            'timestamp': -4e6
        }]

        nusc = MockNuScenes(self.multiagent_mock_annotations, mock_samples)
        helper = PredictHelper(nusc)
        past = helper.get_past_for_sample('5', 3, True)

        answer = {
            '1': np.array([[-1, -1], [-2, -2], [-3, -3]]),
            '2': np.array([[-1, -1], [-2, -2], [-3, -3]])
        }

        for k in answer:
            np.testing.assert_equal(answer[k], answer[k])
Exemplo n.º 3
0
    def test_get_no_data_when_seconds_0(self):
        mock_samples = [{'token': '1', 'timestamp': 0, 'anns': ['1']}]
        nusc = MockNuScenes(self.mock_annotations, mock_samples)
        helper = PredictHelper(nusc)

        np.testing.assert_equal(
            helper.get_future_for_agent('1', '1', 0, False), np.array([]))
        np.testing.assert_equal(helper.get_past_for_agent('1', '1', 0, False),
                                np.array([]))
        np.testing.assert_equal(helper.get_future_for_sample('1', 0, False),
                                np.array([]))
        np.testing.assert_equal(helper.get_past_for_sample('1', 0, False),
                                np.array([]))
Exemplo n.º 4
0
                cv2.fillPoly(target_rep, pts=[np.int0(box)], color=1)
                rotation_mat = get_rotation_matrix(target_rep.shape,
                                                   yaw + np.pi / 2)
                target_rep = cv2.warpAffine(
                    target_rep, rotation_mat,
                    (target_rep.shape[1], target_rep.shape[0]))
                row_crop, col_crop = get_crops(offset, offset, offset, offset,
                                               res, target_rep.shape[0])
                target_rep = target_rep[row_crop, col_crop]
                #only get location where car is at
                target_rep[target_rep != 1] = 0
                target_rep = cv2.GaussianBlur(target_rep[:, :, 0], (5, 5), 0)

                #get other vehicle representation
                history = helper.get_past_for_sample(token,
                                                     0,
                                                     in_agent_frame=False,
                                                     just_xy=False)
                history = reverse_history(history)
                present_time = helper.get_annotations_for_sample(token)

                history = add_present_time_to_history(present_time, history)
                vehicle_rep = np.zeros((256, 256))
                draw_other_vehicle_boxes(needed_ego_pose, (128, 128),
                                         history,
                                         vehicle_rep,
                                         resolution=res)
                vehicle_rep = cv2.warpAffine(vehicle_rep, rotation_mat,
                                             vehicle_rep.shape)
                row_crop, col_crop = get_crops(offset, offset, offset, offset,
                                               res, target_rep.shape[0])
                vehicle_rep = vehicle_rep[row_crop, col_crop]