Skip to content

Commit

Permalink
rename osfm_reconstruction_file -> odm_reconstruction_file
Browse files Browse the repository at this point in the history
  • Loading branch information
dugalh committed Oct 10, 2023
1 parent 4823620 commit 084e8a0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,8 @@ def odm_dem_file(odm_proj_dir: Path) -> Path:


@pytest.fixture(scope='session')
def osfm_reconstruction_file(odm_proj_dir: Path) -> Path:
""" ODM / OpenSfM reconstruction file. """
def odm_reconstruction_file(odm_proj_dir: Path) -> Path:
""" ODM reconstruction file. """
return odm_proj_dir.joinpath('opensfm', 'reconstruction.json')
# TODO: there is a confusion between odm_* fixtures referring to odm format or odm dataset

Expand Down
34 changes: 17 additions & 17 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ def test_ortho_crs_src(ortho_legacy_ngi_cli_str: str, ngi_image_file: Path, tmp_


def test_ortho_crs_auto(
odm_image_file: Tuple[Path, ...], odm_dem_file: Path, osfm_reconstruction_file: Path, odm_lla_rpy_csv_file: Path,
odm_image_file: Tuple[Path, ...], odm_dem_file: Path, odm_reconstruction_file: Path, odm_lla_rpy_csv_file: Path,
odm_crs: str, tmp_path: Path, runner: CliRunner
):
""" Test ``oty ortho`` auto-determines the CRS for LLA-RPY CSV format exterior parameters. """
cli_str = (
f'ortho --dem {odm_dem_file} --int-param {osfm_reconstruction_file} --ext-param {odm_lla_rpy_csv_file} '
f'ortho --dem {odm_dem_file} --int-param {odm_reconstruction_file} --ext-param {odm_lla_rpy_csv_file} '
f'--out-dir {tmp_path} --res 5 {odm_image_file}'
)
result = runner.invoke(cli, cli_str.split())
Expand All @@ -69,13 +69,13 @@ def test_ortho_crs_auto(


def test_ortho_crs_cli(
odm_image_file: Tuple[Path, ...], odm_dem_file: Path, osfm_reconstruction_file: Path, odm_xyz_opk_csv_file: Path,
odm_image_file: Tuple[Path, ...], odm_dem_file: Path, odm_reconstruction_file: Path, odm_xyz_opk_csv_file: Path,
odm_crs: str, tmp_path: Path, runner: CliRunner
):
""" Test ``oty ortho`` uses a CRS specified with ``--crs``. """
# use odm_xyz_opk_csv_file external params so there is no auto-crs
cli_str = (
f'ortho --dem {odm_dem_file} --int-param {osfm_reconstruction_file} --ext-param {odm_xyz_opk_csv_file} '
f'ortho --dem {odm_dem_file} --int-param {odm_reconstruction_file} --ext-param {odm_xyz_opk_csv_file} '
f'--out-dir {tmp_path} --crs {odm_crs} --res 5 {odm_image_file}'
)
result = runner.invoke(cli, cli_str.split())
Expand All @@ -88,7 +88,7 @@ def test_ortho_crs_cli(


def test_ortho_crs_prj(
odm_image_file: Tuple[Path, ...], odm_dem_file: Path, osfm_reconstruction_file: Path, odm_xyz_opk_csv_file: Path,
odm_image_file: Tuple[Path, ...], odm_dem_file: Path, odm_reconstruction_file: Path, odm_xyz_opk_csv_file: Path,
odm_crs: str, tmp_path: Path, runner: CliRunner
):
""" Test ``oty ortho`` uses reads the CRS in a CSV exterior parameter .prj file. """
Expand All @@ -100,7 +100,7 @@ def test_ortho_crs_prj(

# create ortho & test
cli_str = (
f'ortho --dem {odm_dem_file} --int-param {osfm_reconstruction_file} --ext-param {csv_file} '
f'ortho --dem {odm_dem_file} --int-param {odm_reconstruction_file} --ext-param {csv_file} '
f'--out-dir {tmp_path} --res 5 {odm_image_file}'
)
result = runner.invoke(cli, cli_str.split())
Expand All @@ -113,12 +113,12 @@ def test_ortho_crs_prj(


def test_ortho_crs_missing_error(
odm_image_file: Tuple[Path, ...], odm_dem_file: Path, osfm_reconstruction_file: Path, odm_xyz_opk_csv_file: Path,
odm_image_file: Tuple[Path, ...], odm_dem_file: Path, odm_reconstruction_file: Path, odm_xyz_opk_csv_file: Path,
odm_crs: str, tmp_path: Path, runner: CliRunner
):
""" Test ``oty ortho`` raises an error when ``--crs`` is needed but not passed. """
cli_str = (
f'ortho --dem {odm_dem_file} --int-param {osfm_reconstruction_file} --ext-param {odm_xyz_opk_csv_file} '
f'ortho --dem {odm_dem_file} --int-param {odm_reconstruction_file} --ext-param {odm_xyz_opk_csv_file} '
f'--out-dir {tmp_path} {odm_image_file}'
)
result = runner.invoke(cli, cli_str.split())
Expand Down Expand Up @@ -278,15 +278,15 @@ def test_ortho_per_band(ortho_legacy_ngi_cli_str: str, tmp_path: Path, runner: C


def test_ortho_full_remap(
odm_image_file: Tuple[Path, ...], odm_dem_file: Path, osfm_reconstruction_file: Path, tmp_path: Path,
odm_image_file: Tuple[Path, ...], odm_dem_file: Path, odm_reconstruction_file: Path, tmp_path: Path,
runner: CliRunner
):
""" Test ``oty ortho --full-remap`` by comparing ``--full-remap`` and ``--no-full-remap`` orthos. """
# create --full-remap ortho
out_dir_full_remap = tmp_path.joinpath('full_remap')
out_dir_full_remap.mkdir()
cli_str = (
f'ortho --dem {odm_dem_file} --int-param {osfm_reconstruction_file} --ext-param {osfm_reconstruction_file} '
f'ortho --dem {odm_dem_file} --int-param {odm_reconstruction_file} --ext-param {odm_reconstruction_file} '
f'--out-dir {out_dir_full_remap} --res 1 --compress deflate --full-remap {odm_image_file}'
)
result = runner.invoke(cli, cli_str.split())
Expand All @@ -298,7 +298,7 @@ def test_ortho_full_remap(
out_dir_no_full_remap = tmp_path.joinpath('no_full_remap')
out_dir_no_full_remap.mkdir()
cli_str = (
f'ortho --dem {odm_dem_file} --int-param {osfm_reconstruction_file} --ext-param {osfm_reconstruction_file} '
f'ortho --dem {odm_dem_file} --int-param {odm_reconstruction_file} --ext-param {odm_reconstruction_file} '
f'--out-dir {out_dir_no_full_remap} --res 1 --compress deflate --no-full-remap {odm_image_file}'
)
result = runner.invoke(cli, cli_str.split())
Expand All @@ -320,15 +320,15 @@ def test_ortho_full_remap(


def test_ortho_alpha(
odm_image_file: Tuple[Path, ...], odm_dem_file: Path, osfm_reconstruction_file: Path, tmp_path: Path,
odm_image_file: Tuple[Path, ...], odm_dem_file: Path, odm_reconstruction_file: Path, tmp_path: Path,
runner: CliRunner
):
""" Test ``oty ortho --alpha`` by comparing ``--alpha 0`` and ``--alpha 1`` orthos. """
# create --alpha 1 ortho
out_dir_alpha_1 = tmp_path.joinpath('alpha_1')
out_dir_alpha_1.mkdir()
cli_str = (
f'ortho --dem {odm_dem_file} --int-param {osfm_reconstruction_file} --ext-param {osfm_reconstruction_file} '
f'ortho --dem {odm_dem_file} --int-param {odm_reconstruction_file} --ext-param {odm_reconstruction_file} '
f'--out-dir {out_dir_alpha_1} --res 1 --compress deflate --no-full-remap --alpha 1 {odm_image_file}'
)
result = runner.invoke(cli, cli_str.split())
Expand All @@ -340,7 +340,7 @@ def test_ortho_alpha(
out_dir_alpha_0 = tmp_path.joinpath('alpha_0')
out_dir_alpha_0.mkdir()
cli_str = (
f'ortho --dem {odm_dem_file} --int-param {osfm_reconstruction_file} --ext-param {osfm_reconstruction_file} '
f'ortho --dem {odm_dem_file} --int-param {odm_reconstruction_file} --ext-param {odm_reconstruction_file} '
f'--out-dir {out_dir_alpha_0} --res 1 --compress deflate --no-full-remap --alpha 0 {odm_image_file}'
)
result = runner.invoke(cli, cli_str.split())
Expand Down Expand Up @@ -371,15 +371,15 @@ def test_ortho_alpha_error(ortho_legacy_ngi_cli_str: str, tmp_path: Path, runner


def test_ortho_lla_crs(
odm_image_file: Tuple[Path, ...], odm_dem_file: Path, osfm_reconstruction_file: Path, odm_lla_rpy_csv_file: Path,
odm_image_file: Tuple[Path, ...], odm_dem_file: Path, odm_reconstruction_file: Path, odm_lla_rpy_csv_file: Path,
odm_crs: str, tmp_path: Path, runner: CliRunner
):
""" Test ``oty ortho --lla-crs`` by comparing orthos created with different ``--lla-crs`` values. """
# create an ortho with ellipsoidal height --lla-crs
out_dir_ellps = tmp_path.joinpath('lla_crs_ellps')
out_dir_ellps.mkdir()
cli_str = (
f'ortho --dem {odm_dem_file} --int-param {osfm_reconstruction_file} --ext-param {odm_lla_rpy_csv_file} '
f'ortho --dem {odm_dem_file} --int-param {odm_reconstruction_file} --ext-param {odm_lla_rpy_csv_file} '
f'--out-dir {out_dir_ellps} --res 5 --crs {odm_crs}+4326 --lla-crs EPSG:4326+4326 {odm_image_file}'
)
result = runner.invoke(cli, cli_str.split())
Expand All @@ -391,7 +391,7 @@ def test_ortho_lla_crs(
out_dir_geoid = tmp_path.joinpath('lla_crs_geoid')
out_dir_geoid.mkdir()
cli_str = (
f'ortho --dem {odm_dem_file} --int-param {osfm_reconstruction_file} --ext-param {odm_lla_rpy_csv_file} '
f'ortho --dem {odm_dem_file} --int-param {odm_reconstruction_file} --ext-param {odm_lla_rpy_csv_file} '
f'--out-dir {out_dir_geoid} --res 5 --crs {odm_crs}+4326 --lla-crs EPSG:4326+3855 {odm_image_file}'
)
result = runner.invoke(cli, cli_str.split())
Expand Down
22 changes: 11 additions & 11 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def test_csv_reader_xyz_opk(ngi_xyz_opk_csv_file: Path, ngi_crs: str, ngi_image_


def test_csv_reader_lla_rpy(
odm_lla_rpy_csv_file: Path, odm_crs: str, odm_image_files: Tuple[Path, ...], osfm_reconstruction_file: Path
odm_lla_rpy_csv_file: Path, odm_crs: str, odm_image_files: Tuple[Path, ...], odm_reconstruction_file: Path
):
""" Test reading exterior parameters from an lla_rpy format CSV file with a header. """
reader = io.CsvReader(odm_lla_rpy_csv_file, crs=odm_crs)
Expand All @@ -300,7 +300,7 @@ def test_csv_reader_lla_rpy(
file_keys = [filename.name for filename in odm_image_files]
assert set(ext_param_dict.keys()).issubset(file_keys)

with open(osfm_reconstruction_file, 'r') as f:
with open(odm_reconstruction_file, 'r') as f:
json_obj = json.load(f)
cam_id = next(iter(json_obj[0]['cameras'].keys())).strip('v2 ')
_validate_ext_param_dict(ext_param_dict, cameras=[cam_id])
Expand Down Expand Up @@ -397,7 +397,7 @@ def test_csv_reader_format(
dict(delimiter='\t', lineterminator='\n', quotechar='"', quoting=csv.QUOTE_MINIMAL),
]) # yapf: disable
def test_csv_reader_dialect(
odm_lla_rpy_csv_file: Path, odm_crs: str, odm_image_files: Tuple[Path, ...], osfm_reconstruction_file: Path,
odm_lla_rpy_csv_file: Path, odm_crs: str, odm_image_files: Tuple[Path, ...], odm_reconstruction_file: Path,
dialect: Dict, tmp_path: Path
):
""" Test reading exterior parameters from CSV files in different dialects. """
Expand All @@ -419,15 +419,15 @@ def test_csv_reader_dialect(
# validate dict
file_keys = [filename.name for filename in odm_image_files]
assert set(ext_param_dict.keys()).issubset(file_keys)
with open(osfm_reconstruction_file, 'r') as f:
with open(odm_reconstruction_file, 'r') as f:
json_obj = json.load(f)
cam_id = next(iter(json_obj[0]['cameras'].keys())).strip('v2 ')
_validate_ext_param_dict(ext_param_dict, cameras=[cam_id])


def test_osfm_reader(osfm_reconstruction_file: Path, odm_crs: str):
def test_osfm_reader(odm_reconstruction_file: Path, odm_crs: str):
""" Test OsfmReader reads internal and external parameters successfully. """
reader = io.OsfmReader(osfm_reconstruction_file, crs=odm_crs)
reader = io.OsfmReader(odm_reconstruction_file, crs=odm_crs)
assert reader.crs == rio.CRS.from_string(odm_crs)

int_param_dict = reader.read_int_param()
Expand All @@ -440,16 +440,16 @@ def test_osfm_reader(osfm_reconstruction_file: Path, odm_crs: str):
assert ext_cam_ids.issubset(int_cam_ids)


def test_osfm_reader_auto_crs(osfm_reconstruction_file: Path, odm_crs: str):
def test_osfm_reader_auto_crs(odm_reconstruction_file: Path, odm_crs: str):
""" Test OsfmReader auto determines a UTM CRS correctly. """
reader = io.OsfmReader(osfm_reconstruction_file, crs=None)
reader = io.OsfmReader(odm_reconstruction_file, crs=None)
assert reader.crs == rio.CRS.from_string(odm_crs)


def test_osfm_reader_validity_error(odm_int_param_file: Path):
""" Test OsfmReader raises an error with an invalid file format. """
with pytest.raises(ParamFileError) as ex:
reader = io.OsfmReader(odm_int_param_file, crs=None)
_ = io.OsfmReader(odm_int_param_file, crs=None)
assert 'valid' in str(ex)


Expand Down Expand Up @@ -493,10 +493,10 @@ def test_oty_reader(ngi_oty_ext_param_file: Path, ngi_crs: str):
_validate_ext_param_dict(ext_param_dict, cameras=None)


def test_oty_reader_validity_error(osfm_reconstruction_file: Path):
def test_oty_reader_validity_error(odm_reconstruction_file: Path):
""" Test OtyReader raises an error with an invalid file format. """
with pytest.raises(ParamFileError) as ex:
_ = io.OtyReader(osfm_reconstruction_file, crs=None)
_ = io.OtyReader(odm_reconstruction_file, crs=None)
assert 'valid' in str(ex)


Expand Down
4 changes: 2 additions & 2 deletions tests/test_ortho.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,10 +922,10 @@ def test_process_ngi(


def test_process_odm(
odm_image_files: Tuple[Path, ...], odm_dem_file: Path, osfm_reconstruction_file: Path, odm_crs: str, tmp_path: Path
odm_image_files: Tuple[Path, ...], odm_dem_file: Path, odm_reconstruction_file: Path, odm_crs: str, tmp_path: Path
):
""" Test integration and ortho overlap using ODM drone images. """
reader = io.OsfmReader(osfm_reconstruction_file, crs=odm_crs)
reader = io.OsfmReader(odm_reconstruction_file, crs=odm_crs)
int_param_dict = reader.read_int_param()
ext_param_dict = reader.read_ext_param()
camera = create_camera(**next(iter(int_param_dict.values())))
Expand Down

0 comments on commit 084e8a0

Please sign in to comment.