Browse Source

Save homography and use better ransac_threshold

Danghor 1 year ago
parent
commit
b6673ac3d2
1 changed files with 4 additions and 2 deletions
  1. 4 2
      main.py

+ 4 - 2
main.py

@@ -4,7 +4,7 @@ def print_hi(name):
     print(f'Hi, {name}')
 
     # RANSAC Parameters
-    ransac_threshold = 5.0  # inlier threshold
+    ransac_threshold = 0.02  # inlier threshold
     p = 0.35                # probability that any given correspondence is valid
     k = 4                   # number of samples drawn per iteration
     z = 0.99                # total probability of success after all iterations
@@ -18,6 +18,7 @@ def print_hi(name):
     # recompute homography matrix based on inliers
     H = recompute_homography(inliers)
     print(H)
+    np.savetxt('C:\\Git\\git.tk.informatik.tu-darmstadt.de\\StreetLight\\Assets\\StreamingAssets\\homography.csv', H)
 
 def ransac_iters(p, k, z):
     """ Computes the required number of iterations for RANSAC.
@@ -79,6 +80,7 @@ def ransac(pairs, n_iters, k, threshold):
     We execute the ransac loop n_iters times, so that we have a good chance to have a valid homography.
     """
     for iteration in range(n_iters):
+        print(iteration)
         """
         First, we pick a sample of k corresponding point pairs
         """
@@ -178,7 +180,7 @@ def pick_samples(p1, p2, k):
     n = p1.shape[0]
     generator = np.random.default_rng()
     random_numbers = generator.choice(n, size=k, replace=False)
-    random_numbers = np.array([96, 93, 63, 118])
+    #random_numbers = np.array([96, 93, 63, 118])
     sample1 = p1[random_numbers]
     sample2 = p2[random_numbers]