Exemple #1
0
 def test_sum(self):
     descriptors = [
         dbow.ORB([0, 1, 0, 0, 1]),
         dbow.ORB([1, 1, 1, 1, 1]),
         dbow.ORB([0, 0, 0, 1, 0]),
         dbow.ORB([0, 1, 0, 0, 1]),
     ]
     np.allclose(np.sum(descriptors).features, np.array([1, 3, 1, 2, 3]))
Exemple #2
0
    def test_mean(self):
        descriptors = [
            dbow.ORB([0, 1, 0, 0, 1]),
            dbow.ORB([1, 1, 1, 1, 1]),
            dbow.ORB([0, 0, 0, 1, 0]),
            dbow.ORB([0, 1, 0, 0, 1]),
        ]

        self.assertEqual(dbow.mean_value(descriptors),
                         dbow.ORB([0, 1, 0, 1, 1]))
Exemple #3
0
 def test_weight(self):
     descriptors = [
         dbow.ORB([0, 1, 0, 0, 1]),
         dbow.ORB([1, 1, 1, 1, 1]),
         dbow.ORB([0, 0, 0, 1, 0]),
         dbow.ORB([0, 1, 0, 0, 1]),
     ]
     word = dbow.Word(descriptors)
     word.update_weight(4)
     self.assertEqual(word.weight, 0.0)
Exemple #4
0
 def test_tree(self):
     descriptors = [
         dbow.ORB([0, 1, 0, 0, 1]),
         dbow.ORB([1, 1, 1, 1, 1]),
         dbow.ORB([0, 0, 0, 1, 0]),
         dbow.ORB([0, 1, 0, 0, 1]),
     ]
     root = dbow.Node(descriptors)
     words = dbow.initialize_tree(root, 4, 4)
     for i, word in enumerate(words):
         self.assertEqual(word.idx, i)
Exemple #5
0
 def test_distance(self):
     desc1 = dbow.ORB([0, 1, 0, 0, 1])
     desc2 = dbow.ORB([1, 1, 1, 1, 1])
     self.assertEqual(desc1.distance(desc2), 3)