def test_compute_disparity_1_msk_ref(): """ Test compute_disparity on ventoux dataset with pandora """ left_input = xr.open_dataset(absolute_data_path("input/intermediate_results/data1_ref_left_masked.nc")) right_input = xr.open_dataset(absolute_data_path("input/intermediate_results/data1_ref_right.nc")) # Pandora configuration corr_cfg = create_corr_conf() disp_min = -13 disp_max = 14 output = stereo.compute_disparity(left_input, right_input, corr_cfg, disp_min, disp_max, verbose = True) assert output['ref']['disp'].shape == (120, 110) assert output['ref']['msk'].shape == (120, 110) np.testing.assert_allclose(output['ref'].attrs["roi"], np.array([420, 200, 530, 320])) # Uncomment to update baseline #output['ref'].to_netcdf(absolute_data_path("ref_output/disp1_ref_pandora_msk_ref.nc")) #output['sec'].to_netcdf(absolute_data_path("ref_output/disp1_sec_pandora_msk_ref.nc")) ref = xr.open_dataset(absolute_data_path("ref_output/disp1_ref_pandora_msk_ref.nc")) assert_same_datasets(output['ref'],ref,atol=5.e-6) sec = xr.open_dataset(absolute_data_path("ref_output/disp1_sec_pandora_msk_ref.nc")) assert_same_datasets(output['sec'], sec, atol=5.e-6)
def test_compute_disparity_1_msk_sec( images_and_grids_conf): #pylint: disable=redefined-outer-name """ Test compute_disparity on ventoux dataset with pandora """ left_input = xr.open_dataset( absolute_data_path( "input/intermediate_results/data1_ref_left.nc")) right_input = xr.open_dataset( absolute_data_path( "input/intermediate_results/data1_ref_right_masked.nc")) conf = deepcopy(images_and_grids_conf) conf['input']['mask2_classes'] = absolute_data_path( "input/intermediate_results/data1_ref_right_mask_classes.json") # Pandora configuration corr_cfg = create_corr_conf() disp_min = -13 disp_max = 14 output = stereo.compute_disparity(left_input, right_input, conf, corr_cfg, disp_min, disp_max, verbose=True) assert output[cst.STEREO_REF][cst.DISP_MAP].shape == (120, 110) assert output[cst.STEREO_REF][cst.DISP_MSK].shape == (120, 110) assert output[cst.STEREO_SEC][cst.DISP_MAP].shape == (160, 177) assert output[cst.STEREO_SEC][cst.DISP_MSK].shape == (160, 177) np.testing.assert_allclose( output[cst.STEREO_REF].attrs[cst.ROI], np.array([420, 200, 530, 320])) np.testing.assert_allclose( output[cst.STEREO_SEC].attrs[cst.ROI], np.array([420, 200, 530, 320])) np.testing.assert_allclose( output[cst.STEREO_SEC].attrs[cst.ROI_WITH_MARGINS], np.array([387, 180, 564, 340])) # Uncomment to update baseline # output[cst.STEREO_REF].to_netcdf(absolute_data_path( # "ref_output/disp1_ref_pandora_msk_sec.nc")) # output[cst.STEREO_SEC].to_netcdf(absolute_data_path( # "ref_output/disp1_sec_pandora_msk_sec.nc")) ref = xr.open_dataset( absolute_data_path( "ref_output/disp1_ref_pandora_msk_sec.nc")) assert_same_datasets(output[cst.STEREO_REF],ref,atol=5.e-6) sec = xr.open_dataset( absolute_data_path( "ref_output/disp1_sec_pandora_msk_sec.nc")) assert_same_datasets(output[cst.STEREO_SEC], sec, atol=5.e-6)
def test_compute_disparity_3( images_and_grids_conf): #pylint: disable=redefined-outer-name """ Test compute_disparity on paca dataset with pandora """ left_input = xr.open_dataset(absolute_data_path( "input/intermediate_results/data3_ref_left.nc")) right_input = xr.open_dataset(absolute_data_path( "input/intermediate_results/data3_ref_right.nc")) # Pandora configuration corr_cfg = create_corr_conf() disp_min = -43 disp_max = 41 output = stereo.compute_disparity(left_input, right_input, images_and_grids_conf, corr_cfg, disp_min, disp_max) assert output[cst.STEREO_REF][cst.DISP_MAP].shape == (90, 90) assert output[cst.STEREO_REF][cst.DISP_MSK].shape == (90, 90) assert output[cst.STEREO_SEC][cst.DISP_MAP].shape == (170, 254) assert output[cst.STEREO_SEC][cst.DISP_MSK].shape == (170, 254) np.testing.assert_allclose( output[cst.STEREO_REF].attrs[cst.ROI], np.array([16500, 23160, 16590, 23250])) np.testing.assert_allclose( output[cst.STEREO_SEC].attrs[cst.ROI], np.array([16500, 23160, 16590, 23250])) np.testing.assert_allclose( output[cst.STEREO_SEC].attrs[cst.ROI_WITH_MARGINS], np.array([16417, 23120, 16671, 23290])) # Uncomment to update baseline # output[cst.STEREO_REF].to_netcdf(absolute_data_path( # "ref_output/disp3_ref_pandora.nc")) # output[cst.STEREO_SEC].to_netcdf(absolute_data_path( # "ref_output/disp3_sec_pandora.nc")) ref = xr.open_dataset(absolute_data_path( "ref_output/disp3_ref_pandora.nc")) assert_same_datasets(output[cst.STEREO_REF], ref, atol=5.e-6) sec = xr.open_dataset(absolute_data_path( "ref_output/disp3_sec_pandora.nc")) assert_same_datasets(output[cst.STEREO_SEC], sec, atol=5.e-6)
def test_compute_disparity_3(): """ Test compute_disparity on paca dataset with pandora """ left_input = xr.open_dataset(absolute_data_path( "input/intermediate_results/data3_ref_left.nc")) right_input = xr.open_dataset(absolute_data_path( "input/intermediate_results/data3_ref_right.nc")) # Pandora configuration corr_cfg = create_corr_conf() disp_min = -43 disp_max = 41 output = stereo.compute_disparity(left_input, right_input, corr_cfg, disp_min, disp_max) assert output['ref']['disp'].shape == (90, 90) assert output['ref']['msk'].shape == (90, 90) assert output['sec']['disp'].shape == (170, 254) assert output['sec']['msk'].shape == (170, 254) np.testing.assert_allclose(output['ref'].attrs["roi"], np.array([16500, 23160, 16590, 23250])) np.testing.assert_allclose(output['sec'].attrs["roi"], np.array([16500, 23160, 16590, 23250])) np.testing.assert_allclose(output['sec'].attrs["roi_with_margins"], np.array([16417, 23120, 16671, 23290])) # Uncomment to update baseline #output['ref'].to_netcdf(absolute_data_path("ref_output/disp3_ref_pandora.nc")) #output['sec'].to_netcdf(absolute_data_path("ref_output/disp3_sec_pandora.nc")) ref = xr.open_dataset(absolute_data_path( "ref_output/disp3_ref_pandora.nc")) assert_same_datasets(output['ref'], ref, atol=5.e-6) sec = xr.open_dataset(absolute_data_path( "ref_output/disp3_sec_pandora.nc")) assert_same_datasets(output['sec'], sec, atol=5.e-6)