Camera factories

Factories for creating camera models from parameter files and dictionaries.

class orthority.factory.Cameras(**kwargs)

Bases: ABC

Base camera factory class.

abstract property filenames: set[str]

Set of filenames that have cameras.

abstractmethod get(filename)

Return a camera object for the given image filename.

Parameters:

filename (str | PathLike | OpenFile | DatasetReader) – Image filename. Can be a path, URI string, OpenFile instance or dataset.

Returns:

Camera object.

Return type:

Camera

abstractmethod write_param(out_dir, overwrite=False)

Write camera parameters to Orthority format file(s).

Parameters:
  • out_dir (str | PathLike | OpenFile) – Directory to write into. Can be a path, URI string, or an OpenFile object.

  • overwrite (bool) – Whether to overwrite file(s) if they exist.

class orthority.factory.FrameCameras(int_param, ext_param, io_kwargs=None, cam_kwargs=None)

Bases: Cameras

Frame camera factory.

Parameters:
  • int_param (str | PathLike | OpenFile | IO[str] | dict[str, dict]) – Interior parameter file or dictionary. If a file, can be a path or URI string, an OpenFile object or a file object, opened in text mode ('rt').

  • ext_param (str | PathLike | OpenFile | IO[str] | dict[str, dict]) – Exterior parameter file or dictionary. If a file, can be a path or URI string, an OpenFile object or a file object, opened in text mode ('rt').

  • io_kwargs (dict) – Optional dictionary of keyword arguments for the FrameReader sub-class corresponding to the exterior parameter file format. Should exclude ext_param or int_param file names, which are passed internally. If ext_param is a dictionary, these arguments are not passed to the FrameReader sub-class, but FrameCameras.crs is set with the value of a crs argument.

  • cam_kwargs (dict) – Optional dictionary of keyword arguments for the FrameCamera class. Should exclude interior and exterior parameters which are passed internally.

classmethod from_images(files, io_kwargs=None, cam_kwargs=None)

Create frame camera factory from image file(s) with EXIF / XMP tags.

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

  • io_kwargs (dict) – Optional dictionary of keyword arguments for the ExifReader class. Should exclude files which is passed internally.

  • cam_kwargs (dict) – Optional dictionary of keyword arguments for the FrameCamera class. Should exclude interior and exterior parameters which are passed internally.

property crs: CRS | None

CRS of the world coordinate system.

property filenames: set[str]

Set of filenames that have cameras.

get(filename)

Return a camera object for the given image filename.

Parameters:

filename (str | PathLike | OpenFile | DatasetReader) – Image filename. Can be a path, URI string, OpenFile instance or dataset.

Returns:

Camera object.

Return type:

FrameCamera

write_param(out_dir, overwrite=False)

Write camera parameters to Orthority format file(s).

Parameters:
  • out_dir (str | PathLike | OpenFile) – Directory to write into. Can be a path, URI string, or an OpenFile object.

  • overwrite (bool) – Whether to overwrite file(s) if they exist.

class orthority.factory.RpcCameras(rpc_param, cam_kwargs=None)

Bases: Cameras

RPC camera factory.

Parameters:
  • rpc_param (str | PathLike | OpenFile | IO[str] | dict[str, dict]) – Orthority RPC parameter file or dictionary. If a file, can be a path or URI string, an OpenFile object or a file object, opened in text mode ('rt').

  • cam_kwargs (dict) – Optional dictionary of keyword arguments for the RpcCamera class. Should exclude im_size and rpc which are passed internally.

classmethod from_images(files, io_kwargs=None, cam_kwargs=None)

Create RPC camera factory from image file(s) with RPC tags / sidecar file(s).

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

  • io_kwargs (dict) – Optional dictionary of additional arguments for read_im_rpc_param. Should exclude files which is passed internally.

  • cam_kwargs (dict) – Optional dictionary of keyword arguments for the RpcCamera class. Should exclude im_size and rpc which are passed internally.

property filenames: set[str]

Set of filenames that have cameras.

refine(gcps, io_kwargs=None, fit_kwargs=None)

Refine RPC models with GCPs.

Parameters:
get(filename)

Return a camera object for the given image filename.

Parameters:

filename (str | PathLike | OpenFile | DatasetReader) – Image filename. Can be a path, URI string, OpenFile instance or dataset.

Returns:

Camera object.

Return type:

RpcCamera

write_param(out_dir, overwrite=False)

Write camera parameters to Orthority format file(s).

When the models have been refined, the refined models are written, together with the GCPs.

Parameters:
  • out_dir (str | PathLike | OpenFile) – Directory to write into. Can be a path, URI string, or an OpenFile object.

  • overwrite (bool) – Whether to overwrite file(s) if they exist.