def add_point_constraints(ra, reconstruction_shots, reconstruction_name): connections = connected_reconstructions(reconstruction_shots) for connection in connections: i1, (r1, g1) = load_reconstruction(connection[0].submodel_path, connection[0].index) i2, (r2, g2) = load_reconstruction(connection[1].submodel_path, connection[1].index) rec_name1 = reconstruction_name(connection[0]) rec_name2 = reconstruction_name(connection[1]) scale_treshold = 1.3 treshold_in_meter = 0.3 minimum_inliers = 20 status, T, inliers = reconstruction.resect_reconstruction( r1, r2, g1, g2, treshold_in_meter, minimum_inliers) if not status: continue s, R, t = multiview.decompose_similarity_transform(T) if s > scale_treshold or s < (1.0/scale_treshold) or \ len(inliers) < minimum_inliers: continue for t1, t2 in inliers: c1 = r1.points[t1].coordinates c2 = r2.points[t2].coordinates ra.add_common_point_constraint(rec_name1, c1[0], c1[1], c1[2], rec_name2, c2[0], c2[1], c2[2], 1e-1)
def add_point_constraints(ra, reconstruction_shots, reconstruction_name): connections = connected_reconstructions(reconstruction_shots) for connection in connections: i1, (r1, g1) = load_reconstruction( connection[0].submodel_path, connection[0].index) i2, (r2, g2) = load_reconstruction( connection[1].submodel_path, connection[1].index) rec_name1 = reconstruction_name(connection[0]) rec_name2 = reconstruction_name(connection[1]) scale_treshold = 1.3 treshold_in_meter = 0.3 minimum_inliers = 20 status, T, inliers = reconstruction.resect_reconstruction( r1, r2, g1, g2, treshold_in_meter, minimum_inliers) if not status: continue s, R, t = multiview.decompose_similarity_transform(T) if s > scale_treshold or s < (1.0/scale_treshold) or \ len(inliers) < minimum_inliers: continue for t1, t2 in inliers: c1 = r1.points[t1].coordinates c2 = r2.points[t2].coordinates ra.add_common_point_constraint( rec_name1, c1[0], c1[1], c1[2], rec_name2, c2[0], c2[1], c2[2], 1e-1)
def test_absolute_pose_generalized_shot(scene_synthetic_cube): """Whole reconstruction resection (generalized pose) on a toy reconstruction with 0.01 meter point noise and zero outliers.""" noise = 0.01 parameters = config.default_config() scene, tracks_manager = scene_synthetic_cube cluster1, cluster2 = split_synthetic_reconstruction(scene, tracks_manager, 3, noise) cluster2, translation, scale = move_and_scale_cluster(cluster2) status, T, inliers = reconstruction.resect_reconstruction( cluster1, cluster2, tracks_manager, tracks_manager, 2 * noise, parameters["resection_min_inliers"], ) assert status is True s, A, b = multiview.decompose_similarity_transform(T) np.testing.assert_almost_equal(scale, s, 2) np.testing.assert_almost_equal(np.eye(3), A, 2) np.testing.assert_almost_equal(translation, b, 2)