pyorc.CameraConfig#
- class pyorc.CameraConfig(height, width, crs=None, window_size=10, resolution=0.05, bbox=None, camera_matrix=None, dist_coeffs=None, lens_position=None, corners=None, gcps=None, lens_pars=None, calibration_video=None)[source]#
Camera configuration containing information about the perspective of the camera with respect to real world coordinates
- Parameters:
height (int) – height of frame in pixels
width (int) – width of frame in pixels
crs (int, dict or str, optional) – Coordinate Reference System. Accepts EPSG codes (int or str) proj (str or dict) or wkt (str). Only used if the data has no native CRS.
window_size (int) – pixel size of interrogation window (default: 15)
resolution (float, optional) – resolution in m. of projected pixels (default: 0.01)
bbox (shapely.geometry.Polygon, optional) – bounding box in geographical coordinates
lens_position (list of floats (3),) – x, y, z coordinate of lens position in CRS
corners (list of lists of floats (2)) – [x, y] coordinates defining corners of area of interest in camera cols/rows, bbox will be computed from this
gcps (dict) – Can contain “src”: list of 4 lists, with column, row locations in objective of control points, “dst”: list of 4 lists, with x, y locations (local or global coordinate reference system) of control points, “h_ref”: float, measured water level [m] in local reference system (e.g. from staff gauge or pressure gauge) during gcp survey, “z_0”: float, water level [m] in global reference system (e.g. from used GPS system CRS). This must be in the same vertical reference as the measured bathymetry and other survey points, “crs”: int, str or CRS object, CRS in which “dst” points are measured. If None, a local coordinate system is assumed (e.g. from spirit level).
lens_pars (dict, optional) – Lens parameters, containing: “k1”: float, barrel lens distortion parameter (default: 0.), “c”: float, optical center (default: 2.), “f”: float, focal length (default: 1.)
calibration_video (str, optional) – local path to video file containing a checkerboard pattern. Must be 9x6 if called directly, otherwise use
.calibrate_camera
explicitly and providechessboard_size
explicitly. When used, an automated camera calibration on the video file will be attempted.
- __init__(height, width, crs=None, window_size=10, resolution=0.05, bbox=None, camera_matrix=None, dist_coeffs=None, lens_position=None, corners=None, gcps=None, lens_pars=None, calibration_video=None)[source]#
- Parameters:
height (int) – height of frame in pixels
width (int) – width of frame in pixels
crs (int, dict or str, optional) – Coordinate Reference System. Accepts EPSG codes (int or str) proj (str or dict) or wkt (str). Only used if the data has no native CRS.
window_size (int) – pixel size of interrogation window (default: 15)
resolution (float, optional) – resolution in m. of projected pixels (default: 0.01)
bbox (shapely.geometry.Polygon, optional) – bounding box in geographical coordinates
lens_position (list of floats (3),) – x, y, z coordinate of lens position in CRS
corners (list of lists of floats (2)) – [x, y] coordinates defining corners of area of interest in camera cols/rows, bbox will be computed from this
gcps (dict) – Can contain “src”: list of 4 lists, with column, row locations in objective of control points, “dst”: list of 4 lists, with x, y locations (local or global coordinate reference system) of control points, “h_ref”: float, measured water level [m] in local reference system (e.g. from staff gauge or pressure gauge) during gcp survey, “z_0”: float, water level [m] in global reference system (e.g. from used GPS system CRS). This must be in the same vertical reference as the measured bathymetry and other survey points, “crs”: int, str or CRS object, CRS in which “dst” points are measured. If None, a local coordinate system is assumed (e.g. from spirit level).
lens_pars (dict, optional) – Lens parameters, containing: “k1”: float, barrel lens distortion parameter (default: 0.), “c”: float, optical center (default: 2.), “f”: float, focal length (default: 1.)
calibration_video (str, optional) – local path to video file containing a checkerboard pattern. Must be 9x6 if called directly, otherwise use
.calibrate_camera
explicitly and providechessboard_size
explicitly. When used, an automated camera calibration on the video file will be attempted.
Methods
__init__
(height, width[, crs, window_size, ...])- param height:
height of frame in pixels
get_M
([h_a, to_bbox_grid, reverse])Establish a transformation matrix for a certain actual water level h_a.
get_bbox
([camera, h_a, redistort])- param camera:
If set, the bounding box will be returned as row and column coordinates in the camera perspective.
get_depth
(z[, h_a])Retrieve depth for measured bathymetry points using the camera configuration and an actual water level, measured in local reference (e.g.
get_dist_shore
(x, y, z[, h_a])Retrieve depth for measured bathymetry points using the camera configuration and an actual water level, measured in local reference (e.g.
get_dist_wall
(x, y, z[, h_a])get_dst_a
([h_a])h_a : float, optional
get_z_a
([h_a])h_a : float, optional
plot
([figsize, ax, tiles, buffer, ...])Plot the geographical situation of the CameraConfig.
plot_bbox
([ax, camera, transformer, h_a])Plot bounding box for orthorectification in a geographical projection (
camera=False
) or the camera Field Of View (camera=True
).set_bbox_from_corners
(corners)Establish bbox based on a set of camera perspective corner points Assign corner coordinates to camera configuration
set_gcps
(src, dst, z_0[, h_ref, crs])Set ground control points for the given CameraConfig
set_lens_calibration
(fn[, chessboard_size, ...])Calibrates and sets the properties
camera_matrix
anddist_coeffs
using a video of a chessboard pattern.set_lens_pars
([k1, c, f])Set the lens parameters of the given CameraConfig
set_lens_position
(x, y, z[, crs])Set the geographical position of the lens of current CameraConfig.
to_dict
()Return the CameraConfig object as dictionary
to_dict_str
()to_file
(fn)Write the CameraConfig object to json structure
to_json
()Convert CameraConfig object to string
z_to_h
(z)Convert z coordinates of bathymetry to height coordinates in local reference (e.g.
Attributes
Returns geographical bbox fitting around corners points of area of interest in camera perspective
camera_matrix
dist_coeffs
gcp_dims
returns: dims -- amount of dimensions of gcps (can be 2 or 3) :rtype: int
gcp_mean
Get the mean location of gcp destination points
gcp_reduced
Get the location of gcp destination points, reduced with their mean for better local projection
Returns rows and columns in projected frames from
Frames.project
Returns Affine transform of projected frames from
Frames.project