Parameter IO

Parameter file IO and conversions.

orthority.param_io.read_oty_int_param(file)

Read interior parameters for one or more cameras from an Orthority interior parameter file.

Parameters:

file (str | PathLike | OpenFile | IO[str]) – File to read. Can be a path or URI string, an OpenFile object or a file object, opened in text mode ('rt').

Return type:

dict[str, dict[str, Any]]

orthority.param_io.read_osfm_int_param(file)

Read interior parameters for one or more cameras, from an OpenDroneMap cameras.json or OpenSfM reconstruction.json file.

See the format documentation for supported camera models.

Parameters:

file (str | PathLike | OpenFile | IO[str]) – File to read. Can be a path or URI string, an OpenFile object or a file object, opened in text mode ('rt').

Return type:

dict[str, dict[str, Any]]

orthority.param_io.read_exif_int_param(file)

Read interior parameters for a camera from an image file with EXIF / XMP tags.

See the format documentation for required tags.

Parameters:

file (str | PathLike | OpenFile | DatasetReader) – File to read. Can be a path or URI string, an OpenFile object in binary mode ('rb'), or a dataset reader.

Return type:

dict[str, dict[str, Any]]

orthority.param_io.read_im_rpc_param(files, progress=False)

Read RPC camera parameters from image file(s) with RPC tags / sidecar file(s).

Parameters:
  • files (Sequence[str | PathLike | OpenFile | DatasetReader]) – File(s) to read as a list of paths or URI strings, OpenFile objects in binary mode ('rb'), or dataset readers.

  • progress (bool | dict) – Whether to display a progress bar monitoring the portion of files read. Can be set to a dictionary of arguments for a custom tqdm bar.

Return type:

dict[str, dict[str, Any]]

orthority.param_io.read_oty_rpc_param(file)

Read RPC parameters for one or more cameras from an Orthority RPC file.

Parameters:

file (str | PathLike | OpenFile | IO[str]) – File to read. Can be a path or URI string, an OpenFile object or a file object, opened in text mode ('rt').

Return type:

dict[str, dict[str, Any]]

orthority.param_io.read_im_gcps(files, progress=False)

Read GCPs from tags in image file(s).

Parameters:
  • files (Sequence[str | PathLike | OpenFile | DatasetReader]) – File(s) to read as a list of paths or URI strings, OpenFile objects in binary mode ('rb'), or dataset readers.

  • progress (bool | dict) –

    Whether to display a progress bar monitoring the portion of files read. Can be set to a dictionary of arguments for a custom tqdm bar.

Return type:

dict[str, list[dict]]

orthority.param_io.read_oty_gcps(file)

Read GCPs for one or more images from an Orthority GCP file.

Parameters:

file (str | PathLike | OpenFile | IO[str]) – File to read. Can be a path or URI string, an OpenFile object or a file object, opened in text mode ('rt').

Return type:

dict[str, list[dict]]

orthority.param_io.write_int_param(file, int_param_dict, overwrite=False)

Write interior parameters to an Orthority interior parameter file.

Parameters:
  • file (str | PathLike | OpenFile | IO[str]) – File to write. Can be a path or URI string, an OpenFile object or a file object, opened in text mode ('wt').

  • int_param_dict (dict[str, dict[str, Any]]) – Interior parameters to write.

  • overwrite (bool) – Whether to overwrite the file if it exists.

Return type:

None

orthority.param_io.write_ext_param(file, ext_param_dict, crs, overwrite=False)

Write exterior parameters to an Orthority exterior parameter file.

Parameters:
  • file (str | PathLike | OpenFile | IO[str]) – File to write. Can be a path or URI string, an OpenFile object or a file object, opened in text mode ('wt').

  • ext_param_dict (dict[str, dict[str, Any]]) – Exterior parameters to write.

  • crs (str | CRS) – CRS of the world coordinate system as an EPSG, WKT or proj4 string; or CRS object.

  • overwrite (bool) – Whether to overwrite the file if it exists.

Return type:

None

orthority.param_io.write_rpc_param(file, rpc_param_dict, overwrite=False)

Write RPC parameters to an Orthority RPC parameter file.

Parameters:
  • file (str | PathLike | OpenFile | IO[str]) – File to write. Can be a path or URI string, an OpenFile object or a file object, opened in text mode ('wt').

  • rpc_param_dict (dict[str, dict[str, Any]]) – RPC parameters to write.

  • overwrite (bool) – Whether to overwrite the file if it exists.

Return type:

None

orthority.param_io.write_gcps(file, gcp_dict, overwrite=False)

Write GCPs to an Orthority GCP file.

Parameters:
  • file (str | PathLike | OpenFile | IO[str]) – File to write. Can be a path or URI string, an OpenFile object or a file object, opened in text mode ('wt').

  • gcp_dict (dict[str, list[dict]]) – GCPs to write.

  • overwrite (bool) – Whether to overwrite the file if it exists.

Return type:

None

class orthority.param_io.FrameReader(crs=None, lla_crs=CRS.from_epsg(4979))

Bases: ABC

Base frame camera parameter reader.

Parameters:
  • crs (str | CRS) – CRS of the world coordinate system as an EPSG, WKT or proj4 string; or CRS object.

  • lla_crs (str | CRS) – CRS of input geographic coordinates (if any), as an EPSG, WKT or proj4 string; or CRS object.

property crs: CRS

CRS of the world coordinate system.

abstractmethod read_ext_param()

Read exterior camera parameters.

Return type:

dict[str, dict[str, Any]]

class orthority.param_io.CsvReader(file, crs=None, lla_crs=CRS.from_epsg(4979), fieldnames=None, dialect=None, radians=False, **kwargs)

Bases: FrameReader

Exterior parameter reader for a CSV file.

Reads tabular data from a CSV file with a row per source image and column fields for image file name, camera position, orientation and ID.

See the CSV documentation for details on supported fields and formats.

Parameters:
  • file (str | PathLike | OpenFile | IO[str]) – File to read. Can be a path or URI string, an OpenFile object or a file object, opened in text mode ('rt').

  • crs (str | CRS) – CRS of the world coordinate system as an EPSG, WKT or proj4 string; or CRS object. If set to None (the default), and the file contains (x, y, z) world coordinate positions, a CRS can be provided via a .prj sidecar file. If set to None, and the file contains (latitude, longitude, altitude) and (roll, pitch, yaw) fields, a UTM CRS will be auto-determined. If the file contains (latitude, longitude, altitude) or (roll, pitch, yaw) fields (but not both), crs should be supplied.

  • lla_crs (str | CRS) – Geographic CRS associated with any (latitude, longitude, altitude) position and/or (roll, pitch, yaw) values in the file (as an EPSG, WKT or proj4 string; or CRS object).

  • fieldnames (Sequence[str]) – List of names specifying the CSV fields. If set to None (the default), names will be read from the file header if it exists. If fieldnames is supplied, any existing file header is ignored. See the CSV documentation for recognised and required field names.

  • dialect (Dialect) – Dialect object specifying the CSV delimiter, quote character etc. If set to None (the default), this is auto-detected from the file.

  • radians (bool) – Whether orientation angles are in radians (True), or degrees (False).

read_ext_param()

Read exterior camera parameters.

Return type:

dict[str, dict[str, Any]]

class orthority.param_io.OsfmReader(file, crs=None, lla_crs=CRS.from_epsg(4326), **kwargs)

Bases: FrameReader

Interior and exterior parameter reader for an OpenSfM reconstruction.json file.

See the format documentation for supported camera models.

Parameters:
  • file (str | PathLike | OpenFile | IO[str]) – File to read. Can be a path or URI string, an OpenFile object or a file object, opened in text mode ('rt').

  • crs (str | CRS) – CRS of the world coordinate system as an EPSG, WKT or proj4 string; or CRS object. If set to None (the default), a UTM CRS will be auto-determined.

  • lla_crs (str | CRS) – CRS of the reference_lla value in the reconstruction.json file as an EPSG, WKT or proj4 string; or CRS object.

read_int_param()

Read interior camera parameters.

Return type:

dict[str, dict[str, Any]]

read_ext_param()

Read exterior camera parameters.

Return type:

dict[str, dict[str, Any]]

class orthority.param_io.ExifReader(files, crs=None, lla_crs=CRS.from_epsg(4979), progress=False, **kwargs)

Bases: FrameReader

Interior and exterior parameter reader for image file(s) with EXIF / XMP tags.

See the format documentation for required tags.

Parameters:
  • files (Sequence[str | PathLike | OpenFile | rio.DatasetReader]) – File(s) to read as a list of paths or URI strings, OpenFile objects in binary mode ('rb'), or dataset readers.

  • crs (str | CRS) – CRS of the world coordinate system as an EPSG, WKT or proj4 string; or CRS object. If set to None (the default), a UTM CRS will be auto-determined.

  • lla_crs (str | CRS) – CRS of geographic camera coordinates in the EXIF / XMP tags as an EPSG, WKT or proj4 string; or CRS object.

  • progress (bool | dict) –

    Whether to display a progress bar monitoring the portion of files read. Can be set to a dictionary of arguments for a custom tqdm bar.

read_int_param()

Read interior camera parameters.

Return type:

dict[str, dict[str, Any]]

read_ext_param()

Read exterior camera parameters.

Return type:

dict[str, dict[str, Any]]

class orthority.param_io.OtyReader(file, **kwargs)

Bases: FrameReader

Exterior parameter reader for an Orthority exterior parameter file.

Parameters:

file (str | PathLike | OpenFile | IO[str]) – File to read. Can be a path or URI string, an OpenFile object or a file object, opened in text mode ('rt').

read_ext_param()

Read exterior camera parameters.

Return type:

dict[str, dict[str, Any]]