Loading autocnet/matcher/naive_template.py +5 −1 Original line number Diff line number Diff line Loading @@ -44,8 +44,12 @@ def pattern_match(template, image, upsampling=16, func=cv2.TM_CCORR_NORMED, erro raise ValueError # Fit a 3rd order polynomial to upsample the images if upsampling != 1: u_template = zoom(template, upsampling, order=3) u_image = zoom(image, upsampling, order=3) else: u_template = template u_image = image result = cv2.matchTemplate(u_image, u_template, method=func) _, max_corr, min_loc, max_loc = cv2.minMaxLoc(result) Loading @@ -64,5 +68,5 @@ def pattern_match(template, image, upsampling=16, func=cv2.TM_CCORR_NORMED, erro x += (u_template.shape[1] / 2) x = (x - ideal_x) / upsampling y = (ideal_y - y) / upsampling y = (y - ideal_y) / upsampling return x, y, max_corr autocnet/matcher/subpixel.py +2 −2 Original line number Diff line number Diff line Loading @@ -360,8 +360,8 @@ def iterative_phase(sx, sy, dx, dy, s_img, d_img, size=251, reduction=11, conver except: return None, None, None # Apply the shift to d_search and compute the new correspondence location dx += (shift_x + dxr) dy += (shift_y + dyr) dx += shift_x # The implementation already applies the dxr, dyr shifts dy += shift_y # Break if the solution has converged size = (size[0] - reduction, size[1] - reduction) Loading autocnet/matcher/tests/test_naive_template.py +4 −4 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ class TestNaiveTemplate(unittest.TestCase): self._test_image, upsampling=1) # Test offsets self.assertEqual(result_x, -3) self.assertEqual(result_y, 3) self.assertEqual(result_y, -3) # Test Correlation Strength: At least 0.8 self.assertGreaterEqual(result_strength, 0.8, "Returned Correlation Strength of %d" % result_strength) Loading @@ -58,7 +58,7 @@ class TestNaiveTemplate(unittest.TestCase): self._test_image, upsampling=1) # Test offsets self.assertEqual(result_x, 3) self.assertEqual(result_y, -4) self.assertEqual(result_y, 4) # Test Correlation Strength: At least 0.8 self.assertGreaterEqual(result_strength, 0.8, "Returned Correlation Strength of %d" % result_strength) Loading @@ -67,7 +67,7 @@ class TestNaiveTemplate(unittest.TestCase): self._test_image, upsampling=1) # Test offsets self.assertEqual(result_x, -2) self.assertEqual(result_y, -4) self.assertEqual(result_y, 4) # Test Correlation Strength: At least 0.8 self.assertGreaterEqual(result_strength, 0.8, "Returned Correlation Strength of %d" % result_strength) Loading @@ -76,7 +76,7 @@ class TestNaiveTemplate(unittest.TestCase): self._test_image, upsampling=1) # Test offsets self.assertEqual(result_x, 3) self.assertEqual(result_y, 5) self.assertEqual(result_y, -5) # Test Correlation Strength: At least 0.8 self.assertGreaterEqual(result_strength, 0.8, "Returned Correlation Strength of %d" % result_strength) Loading autocnet/matcher/tests/test_subpixel.py +1 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ def test_subpixel_template(apollo_subsets): assert strength >= 0.99 assert nx == 50.9375 assert ny == 48.9375 assert ny == 53.0625 @pytest.mark.parametrize("convergence_threshold, expected", [(1.0, (None, None, None)), (2.0, (50.49, 52.44, (0.039507, -9.5e-20)))]) Loading Loading
autocnet/matcher/naive_template.py +5 −1 Original line number Diff line number Diff line Loading @@ -44,8 +44,12 @@ def pattern_match(template, image, upsampling=16, func=cv2.TM_CCORR_NORMED, erro raise ValueError # Fit a 3rd order polynomial to upsample the images if upsampling != 1: u_template = zoom(template, upsampling, order=3) u_image = zoom(image, upsampling, order=3) else: u_template = template u_image = image result = cv2.matchTemplate(u_image, u_template, method=func) _, max_corr, min_loc, max_loc = cv2.minMaxLoc(result) Loading @@ -64,5 +68,5 @@ def pattern_match(template, image, upsampling=16, func=cv2.TM_CCORR_NORMED, erro x += (u_template.shape[1] / 2) x = (x - ideal_x) / upsampling y = (ideal_y - y) / upsampling y = (y - ideal_y) / upsampling return x, y, max_corr
autocnet/matcher/subpixel.py +2 −2 Original line number Diff line number Diff line Loading @@ -360,8 +360,8 @@ def iterative_phase(sx, sy, dx, dy, s_img, d_img, size=251, reduction=11, conver except: return None, None, None # Apply the shift to d_search and compute the new correspondence location dx += (shift_x + dxr) dy += (shift_y + dyr) dx += shift_x # The implementation already applies the dxr, dyr shifts dy += shift_y # Break if the solution has converged size = (size[0] - reduction, size[1] - reduction) Loading
autocnet/matcher/tests/test_naive_template.py +4 −4 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ class TestNaiveTemplate(unittest.TestCase): self._test_image, upsampling=1) # Test offsets self.assertEqual(result_x, -3) self.assertEqual(result_y, 3) self.assertEqual(result_y, -3) # Test Correlation Strength: At least 0.8 self.assertGreaterEqual(result_strength, 0.8, "Returned Correlation Strength of %d" % result_strength) Loading @@ -58,7 +58,7 @@ class TestNaiveTemplate(unittest.TestCase): self._test_image, upsampling=1) # Test offsets self.assertEqual(result_x, 3) self.assertEqual(result_y, -4) self.assertEqual(result_y, 4) # Test Correlation Strength: At least 0.8 self.assertGreaterEqual(result_strength, 0.8, "Returned Correlation Strength of %d" % result_strength) Loading @@ -67,7 +67,7 @@ class TestNaiveTemplate(unittest.TestCase): self._test_image, upsampling=1) # Test offsets self.assertEqual(result_x, -2) self.assertEqual(result_y, -4) self.assertEqual(result_y, 4) # Test Correlation Strength: At least 0.8 self.assertGreaterEqual(result_strength, 0.8, "Returned Correlation Strength of %d" % result_strength) Loading @@ -76,7 +76,7 @@ class TestNaiveTemplate(unittest.TestCase): self._test_image, upsampling=1) # Test offsets self.assertEqual(result_x, 3) self.assertEqual(result_y, 5) self.assertEqual(result_y, -5) # Test Correlation Strength: At least 0.8 self.assertGreaterEqual(result_strength, 0.8, "Returned Correlation Strength of %d" % result_strength) Loading
autocnet/matcher/tests/test_subpixel.py +1 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ def test_subpixel_template(apollo_subsets): assert strength >= 0.99 assert nx == 50.9375 assert ny == 48.9375 assert ny == 53.0625 @pytest.mark.parametrize("convergence_threshold, expected", [(1.0, (None, None, None)), (2.0, (50.49, 52.44, (0.039507, -9.5e-20)))]) Loading