示例#1
0
 def test_full(self):
     test_matrix = np.matrix('0.1, 0.2, 4.0; 3.0, 2.0, 0.2')
     fanout = 2
     non_matching_cost = 0.24
     graph = Graph()
     graph.initFromMatrix(test_matrix, fanout)
     graph.computePath()
     img_path = graph.getImageCorrespodences()
     path_real, path_hidden = PT.filterPath(test_matrix, img_path,
                                            non_matching_cost)
     path_real_true = np.array([[1, 2], [0, 1]])
     self.assertEqual(np.sum(path_real - path_real_true), 0)
     self.assertEqual(len(path_hidden), 0)
示例#2
0
        print("[ERROR] Not enough input paramters")
        print("Proper usage: python3 img_seq_matcher.py cost_matrix.txt fanout non_matching_cost")
        sys.exit()

    cost_matrix = np.loadtxt(sys.argv[1])
    # inverting the costs, so that the better the match the smaller is the
    # matching cost
    fanout = int(sys.argv[2])
    # non_matching_cost = 7.5
    non_matching_cost = float(sys.argv[3])

    print("Size of the matrix", cost_matrix.shape)
    print("Max value ", np.max(np.max(cost_matrix)))
    print("Min value ", np.min(np.min(cost_matrix)))
    print("non_matching_cost ", non_matching_cost)
    print("fanout ", fanout)

    graph = Graph()
    graph.initFromMatrix(cost_matrix, fanout)
    graph.computePath()
    img_path = graph.getImageCorrespodences()

    # filter result
    path_coords_real, path_coords_hidden = pt.filterPath(
        cost_matrix, img_path, non_matching_cost)
    print("Done.")

    plt.figure(1)
    pt.plotPathOverMatrix(path_coords_real, path_coords_hidden, cost_matrix)
    plt.show()