def setUp(self): self.tol = 6 self.p1 = np.array([ [99.0825859985542, 1136.84241396289, -1031.66650596755, -117.325418998838], [-301.923289351466, 1760.62028612233, -533.989983528509, 566.900954605729] ]) self.p2 = np.array([ [1829.78818884974, 15378.7866880232, 612.159309750213, 2756.44403323769], [474.180433404958, 4677.92468041337, 1092.76420021176, 1874.89973953780] ]) self.R1 = np.array([ [0.983417707845482, 0.013453875580959, 0.180855204867843], [-0.060089831339915, 0.965084992860598, 0.254951306575981], [-0.171110560940808, -0.261591188282616, 0.949890112669571] ]) self.R2 = np.array([ [0.556837962037774, 0.329755275145440, 0.762360113428931], [-0.787076103923440, 0.502747650438714, 0.357429722618378], [-0.265410419287405, -0.799065866178820, 0.539491474299248] ]) self.sols = dpl.get_valtonenornhag_arxiv_2021_frEfr( np.asfortranarray(self.p1), np.asfortranarray(self.p2), np.asfortranarray(self.R1), np.asfortranarray(self.R2), False )
def test_valtonenornhag_arxiv_2021_frEfr_dimensions02(self): """Check that an exception is raised when dimensions are incorrect.""" p1 = np.random.randn(2, 3) p2 = np.random.randn(2, 2) R1 = np.random.randn(3, 3) R2 = np.random.randn(3, 3) with self.assertRaises(ValueError): sols = dpl.get_valtonenornhag_arxiv_2021_frEfr( # noqa np.asfortranarray(p1), np.asfortranarray(p2), np.asfortranarray(R1), np.asfortranarray(R2), False)
def setUp(self): """This mimicks the example/synthetic script.""" rng = np.random.default_rng(2021) # There are some reproducibility issues between Travis setup and local ones self.tol = 11 N = 4 distortion_param = -1e-07 R1, R2, f, F, x1, x2, R, t, x1u, x2u = generate_points_realistic( N, distortion_param, rng) use_fast_solver = False out = dpl.get_valtonenornhag_arxiv_2021_frEfr( np.asfortranarray(x1[:2, :]), np.asfortranarray(x2[:2, :]), np.asfortranarray(R1), np.asfortranarray(R2), use_fast_solver) self.f_err, self.F_err, self.r_err = compare_to_gt( out, f, F, distortion_param)
r_err = min([abs(r - sol['r']) / abs(r) for sol in sols]) return f_err, F_err, r_err if __name__ == '__main__': # Test a minimal sample print('frEfr:') N = 4 distortion_param = -1e-07 R1, R2, f, F, x1, x2, R, t, x1u, x2u = generate_points_realistic( N, distortion_param) print(f'F =\n{F / F[2, 2]}') print(f'f = {f}') print(f'r = {distortion_param}') print(f'x1 =\n{x1[:2, :]}') print(f'x2 =\n{x2[:2, :]}') use_fast_solver = False out = dpl.get_valtonenornhag_arxiv_2021_frEfr(np.asfortranarray(x1[:2, :]), np.asfortranarray(x2[:2, :]), np.asfortranarray(R1), np.asfortranarray(R2), use_fast_solver) f_err, F_err, r_err = compare_to_gt(out, f, F, distortion_param) print(f'Focal length error: {f_err}') print(f'Fundamental matrix error: {F_err}') print(f'Radial distortion parameter error: {r_err}')