def check_prior(data: dataset.DataSet, output_rec_path: str): reconstruction = data.load_reconstruction() # load old reconstruction prior_rec = data.load_reconstruction(output_rec_path) for shot_id, shot in reconstruction[0].shots.items(): utils.assert_shots_equal(shot, prior_rec[0].shots[shot_id]) assert len(prior_rec[0].points) > 1000
def test_add_pano_shot_from_shot_correct_value(): # Given some created reconstruction (rec) ... n_shots = 5 rec = _create_reconstruction(1, n_pano_shots_cam={"0": n_shots}) shot1 = rec.pano_shots["0"] _helper_populate_metadata(shot1.metadata) # .. and given another one (new) rec_new = _create_reconstruction(1) # When adding 2 pano shot of rec to new rec_new.add_pano_shot(rec.pano_shots["0"]) rec_new.add_pano_shot(rec.pano_shots["1"]) # Then new's shots values should be the same as rec's ones' for k in rec_new.shots.keys(): assert_shots_equal(rec.pano_shots[k], rec_new.pano_shots[k])
def test_rec_deepcopy(): # Given a reconstruction with everything (shots, pano shots, metadata) rec = _create_reconstruction( n_cameras=2, n_shots_cam={ "0": 50, "1": 40 }, n_pano_shots_cam={ "0": 20, "1": 30 }, n_points=200, dist_to_shots=True, ) for shot in rec.shots.values(): _helper_populate_metadata(shot.metadata) for shot in rec.pano_shots.values(): _helper_populate_metadata(shot.metadata) # When we deep-copy it rec2 = copy.deepcopy(rec, {"copy_observations": True}) # It has the expected count of data assert len(rec2.cameras) == 2 assert len(rec2.shots) == 90 assert len(rec2.pano_shots) == 50 assert len(rec2.points) == 200 # Cameras are different objects of same value for k in rec.cameras: cam, cam_cpy = rec.cameras[k], rec2.cameras[k] assert cam != cam_cpy assert_cameras_equal(cam, cam_cpy) # Shots are different objects of same value for shot_id in rec2.shots.keys(): shot1, shot2 = rec.shots[shot_id], rec2.shots[shot_id] assert shot1 is not shot2 assert_shots_equal(shot1, shot2) # Pano shots are different objects of same value for shot_id in rec2.pano_shots.keys(): shot1, shot2 = rec.pano_shots[shot_id], rec2.pano_shots[shot_id] assert shot1 is not shot2 assert_shots_equal(shot1, shot2) # Points are different objects of same value for pt_id in rec2.points: pt, pt_cpy = rec.points[pt_id], rec2.points[pt_id] assert pt != pt_cpy assert pt.id == pt_cpy.id assert np.allclose(pt.coordinates, pt_cpy.coordinates) assert np.allclose(pt.color, pt_cpy.color) obs = pt.get_observations() obs_cpy = pt_cpy.get_observations() assert len(obs) == len(obs_cpy) # Observations are different objects of same value for shot, obs_id in obs.items(): obs1 = shot.get_observation(obs_id) shot_cpy = rec2.shots[shot.id] obs_cpy = shot_cpy.get_observation(obs_id) assert obs1 is not obs_cpy