Exemple #1
0
    def test_del(self):
        t = RandomDict()
        t['a'] = 1
        t['b'] = 2

        del t['a']

        self.assertEqual(2, t['b'])
        self.assertEqual(1, len(t))
        self.assertEqual(2, t.pop('b'))
        self.assertEqual(0, len(t))
matches_list = {}
max_n_try = 500000
n = 0

count_match = 0
while (n < min(max_n_try, possible_n_matches)):
    if len(matches_list) >= N_matches:
        break

    rand_point3D_id, rand_pair_choices = matches.random_item()
    assert (rand_point3D_id not in invalid_points3D_id)
    assert (len(rand_pair_choices) > 0)
    rand_pair_key, rand_pair = rand_pair_choices.random_item()
    rand_pair_choices.pop(rand_pair_key)
    if len(rand_pair_choices) == 0:
        matches.pop(rand_point3D_id)
    n += 1
    image_id1 = rand_pair[0]
    image_id2 = rand_pair[1]
    patch_id1 = point3D_id_image_id_to_patch_id[(rand_point3D_id, image_id1)]
    patch_id2 = point3D_id_image_id_to_patch_id[(rand_point3D_id, image_id2)]
    print('%d/%d %d (img:%d[patch:%d] img:%d[patch:%d])' %
          (n, possible_n_matches, rand_point3D_id, image_id1, patch_id1,
           image_id2, patch_id2))

    key = (patch_id1, patch_id2)
    matches_list[key] = (rand_point3D_id, rand_point3D_id)
    # visualize the matchings
#     if len(matches_list) % 900 == 0:
#         img = np.zeros(shape=(input_sz, input_sz*2), dtype=np.uint8)
#         patch1 = extract_patch_from_grid(patch_id1)