Example #1
0
    def test_read_numpy_array_files_alpha_over_one(self):
        """ Checks the use of the alpha parameter in the loading of sift files.
        """
        # Test loading with alpha = 0
        point_array = sift_util.load_array_from_files(
            file_list=glob.glob('test_data/seminar.sift'), max_points=1369)
        self.assertEqual(point_array.shape[1], 128)
        point_array_1_0 = sift_util.load_array_from_files(
            file_list=glob.glob('test_data/seminar.sift'),
            alpha=1.0,
            max_points=1369)
        self.assertEqual(point_array_1_0.shape[1], 130)
        point_array_2_0 = sift_util.load_array_from_files(
            file_list=glob.glob('test_data/seminar.sift'),
            alpha=2.0,
            max_points=1369)
        self.assertEqual(point_array_2_0.shape[1], 130)

        for d_1, d_2 in itertools.izip(point_array_1_0, point_array_2_0):
            self.assertTrue(
                math.fabs(d_1[-2] * 2.0 - d_2[-2]) <= 1,
                'd_1[-2] = %d, d_2[-2] = %d' % (d_1[-2], d_2[-2]))
            self.assertTrue(
                math.fabs(d_1[-1] * 2.0 - d_2[-1]) <= 1,
                'd_1[-1] = %d, d_2[-1] = %d' % (d_1[-1], d_2[-1]))
Example #2
0
    def test_read_numpy_array_files_alpha_over_one(self):
        """ Checks the use of the alpha parameter in the loading of sift files.
        """
        # Test loading with alpha = 0
        point_array = sift_util.load_array_from_files(file_list=glob.glob('test_data/seminar.sift'), max_points=1369)
        self.assertEqual(point_array.shape[1], 128)
        point_array_1_0 = sift_util.load_array_from_files(file_list=glob.glob('test_data/seminar.sift'), alpha=1.0, max_points=1369)
        self.assertEqual(point_array_1_0.shape[1], 130)
        point_array_2_0 = sift_util.load_array_from_files(file_list=glob.glob('test_data/seminar.sift'), alpha=2.0, max_points=1369)
        self.assertEqual(point_array_2_0.shape[1], 130)

        for d_1, d_2 in itertools.izip(point_array_1_0, point_array_2_0):
            self.assertTrue(math.fabs(d_1[-2] * 2.0 - d_2[-2]) <= 1, 'd_1[-2] = %d, d_2[-2] = %d' % (d_1[-2], d_2[-2]))
            self.assertTrue(math.fabs(d_1[-1] * 2.0 - d_2[-1]) <= 1, 'd_1[-1] = %d, d_2[-1] = %d' % (d_1[-1], d_2[-1]))
Example #3
0
    def test_read_numpy_array_from_files_noalpha(self):
        """ Check the reading of sift descriptors from files.

        This doesn't check the application of the alpha parameter, just
        number of descriptors loaded and that max_points is being
        observed.
        """
        # Test loading from empty list
        point_array = sift_util.load_array_from_files(file_list=[],
                                                      max_points=300)
        self.assertEqual(len(point_array), 0)
        # Test loading with max points less than num available
        point_array = sift_util.load_array_from_files(
            file_list=glob.glob('test_data/seminar.sift'), max_points=300)
        self.assertTrue(len(point_array) > 0)
        self.assertTrue(len(point_array) <= 300)
        # Test loading with max points equal to num available
        point_array = sift_util.load_array_from_files(
            file_list=glob.glob('test_data/seminar.sift'), max_points=1369)
        self.assertEqual(len(point_array), 1369)
        # Test loading with max points not specified
        point_array = sift_util.load_array_from_files(
            file_list=glob.glob('test_data/seminar.sift'))
        self.assertEqual(len(point_array), 1369)
        # Test loading with max points higher than num available
        point_array = sift_util.load_array_from_files(
            file_list=glob.glob('test_data/seminar.sift'), max_points=1500)
        self.assertEqual(len(point_array), 1369)
        # Test loading from list with max points lower than available
        point_array = sift_util.load_array_from_files(
            file_list=glob.glob('test_data/*.sift'), max_points=1369)
        self.assertTrue(len(point_array) <= 1369)
        # Test loading from list with max points lower than available, but higher than a single file
        point_array = sift_util.load_array_from_files(
            file_list=glob.glob('test_data/*.sift'), max_points=1500)
        self.assertTrue(
            len(point_array) >
            1369)  # Check that more descriptors than from a single file
        self.assertTrue(
            len(point_array) <= 1500)  # Check that within max_points
Example #4
0
    def test_read_numpy_array_from_files_noalpha(self):
        """ Check the reading of sift descriptors from files.

        This doesn't check the application of the alpha parameter, just
        number of descriptors loaded and that max_points is being
        observed.
        """
        # Test loading from empty list
        point_array = sift_util.load_array_from_files(file_list=[],
                                                      max_points=300)
        self.assertEqual(len(point_array), 0)
        # Test loading with max points less than num available
        point_array = sift_util.load_array_from_files(
            file_list=glob.glob('test_data/seminar.sift'), max_points=300)
        self.assertTrue(len(point_array) > 0)
        self.assertTrue(len(point_array) <= 300)
        # Test loading with max points equal to num available
        point_array = sift_util.load_array_from_files(
            file_list=glob.glob('test_data/seminar.sift'), max_points=1369)
        self.assertEqual(len(point_array), 1369)
        # Test loading with max points not specified
        point_array = sift_util.load_array_from_files(
            file_list=glob.glob('test_data/seminar.sift'))
        self.assertEqual(len(point_array), 1369)
        # Test loading with max points higher than num available
        point_array = sift_util.load_array_from_files(
            file_list=glob.glob('test_data/seminar.sift'), max_points=1500)
        self.assertEqual(len(point_array), 1369)
        # Test loading from list with max points lower than available
        point_array = sift_util.load_array_from_files(
            file_list=glob.glob('test_data/*.sift'), max_points=1369)
        self.assertTrue(len(point_array) <= 1369)
        # Test loading from list with max points lower than available, but higher than a single file
        point_array = sift_util.load_array_from_files(
            file_list=glob.glob('test_data/*.sift'), max_points=1500)
        self.assertTrue(len(point_array) > 1369) # Check that more descriptors than from a single file
        self.assertTrue(len(point_array) <= 1500) # Check that within max_points