arguslib.camera package

class arguslib.camera.PerspectiveProjection(focal_lengths, principal_point, distortion_coeffs=None)[source]

Bases: object

image_to_view(p_image, norm=False)[source]

Convert an image pixel location to a 3D location using OpenCV undistort.

view_to_image(v_view, normed=False)[source]

Convert a 3D location to a pixel location using OpenCV projection.

class arguslib.camera.Projection(poly_thetar, poly_rz, principal_point)[source]

Bases: object

classmethod fromfile(filename)[source]
image_to_view(p_image, norm=False)[source]

Convert an image pixel location to a 3D location

view_to_image(v_view, normed=False)[source]

Convert a 3D location to a pixel location

class arguslib.camera.Camera(intrinsic_calibration, *args, scale_factor=1, camera_type='allsky', **kwargs)[source]

Bases: Instrument

Represents a camera instrument, handling intrinsic and extrinsic calibration.

This class provides the core functionality for a single camera, including loading configuration, converting between world coordinates and pixel coordinates, and rendering the camera’s view on a plot. It supports both ‘allsky’ fisheye cameras and standard ‘perspective’ cameras.

intrinsic

The intrinsic calibration model.

Type:

Projection

scale_factor

A scaling factor applied to image dimensions.

Type:

float

camera_type

The type of camera, e.g., ‘allsky’ or ‘perspective’.

Type:

str

image_size_px

The dimensions of the camera image in pixels.

Type:

np.ndarray

annotate_positions(positions, dt, ax, *args, plotting_method=None, max_range_km=90, **kwargs)[source]

Annotates one or more geographical positions on the camera image. This version is vectorized for performance.

distance_calibration_img(height_km=10)[source]
classmethod from_config(campaign, camstr, **kwargs)[source]
classmethod from_filename(filename, *args, **kwargs)[source]
iead_to_pix(elevation, azimuth, dist=10)[source]
initialise_data_loader()[source]
pix_to_iead(pix_x, pix_y, distance=None, altitude=None)[source]
radar_beam(target_elevation, target_azimuth, radar)[source]
target_pix(target_position)[source]

Calculates pixel coordinates for a target position. Vectorized to handle a list of positions.

class arguslib.camera.CameraArray(cameras, layout_shape)[source]

Bases: PlottableInstrument

annotate_positions(positions, dt, ax, *args, **kwargs)[source]

Annotate the positions of the cameras on the map.

classmethod from_config(array_name, camera_class=<class 'arguslib.camera.camera.Camera'>)[source]
infer_positions()[source]

Infer the positions of the cameras in the layout, based on the lat/lon under the camera Camera.Position properties.

Return type:

list[tuple[int, int]]

show(dt, ax=None, replace_ax=None, label_cameras=True, **kwargs)[source]

Show the camera array on a map.

class arguslib.camera.DirectCamera(intrinsic_calibration, *args, scale_factor=1, camera_type='allsky', **kwargs)[source]

Bases: Camera

A Camera subclass that renders annotations directly onto the image array.

This class is optimized for performance, especially for creating videos. Instead of using Matplotlib for plotting, it overrides the show and annotate_positions methods to use OpenCV functions (cv2.line, cv2.putText) to draw directly on the image data.

As a result, its show and annotate_positions methods do not accept or return Matplotlib Axes objects. The final image can be accessed via the .image property or .to_image_array() method.

annotate_positions(positions, dt, ax, *args, plotting_method=None, max_range_km=90, **kwargs)[source]

Annotates one or more geographical positions on the camera image. This version is vectorized for performance.

get_data_time(*args, **kwargs)[source]
property image
to_image_array(time=True)[source]
class arguslib.camera.DirectUndistortedCamera(*args, **kwargs)[source]

Bases: UndistortedCamera, DirectCamera

class arguslib.camera.UndistortedCamera(*args, **kwargs)[source]

Bases: Camera

A specialized Camera that applies a fisheye undistortion to images.

This version pre-computes the undistortion mapping for high performance.

get_data_time(*args, **kwargs)[source]
target_pix(target_position)[source]

Calculates pixel coordinates for a target position. Vectorized to handle a list of positions.

class arguslib.camera.Video(filepath)[source]

Bases: object

estimate_frame_number(dt)[source]
get_data_time(dt, return_timestamp=False)[source]

Gets image data at the nearest possible timestamp. Images have 5 second time resolution.

get_frame(n)[source]
get_timestamps(ns=None)[source]
class arguslib.camera.VideoInterface(instrument)[source]

Bases: PlottableInstrument

A PlottableInstrument that uses a DirectCamera to produce video frames and provides utilities for writing these frames to a video file.

add_frame_to_video(dt, show_kwargs=None, time_overlay=True, image_array=None)[source]

Adds a frame for the given datetime ‘dt’ to the video. If image_array is provided (in BGR format), it’s used directly. Otherwise, a frame is generated using the direct_camera.

Parameters:
  • dt (datetime) – Datetime for the frame.

  • show_kwargs (Optional[dict]) – Arguments to pass to self.direct_camera.show().

  • time_overlay (bool) – If True, adds a timestamp overlay to the frame (if generated).

  • image_array (Optional[ndarray]) – Optional pre-rendered BGR numpy array.

Return type:

None

annotate_positions(positions, dt, ax=None, *args, **kwargs)[source]

Delegates annotation to the underlying direct camera. ‘ax’ is expected to be None for DirectCamera.

Return type:

None

finish_video_output()[source]

Releases the video writer and resets video properties.

Return type:

None

generate_video(output_path, start_dt, end_dt, step_timedelta, fps, show_kwargs=None, time_overlay=True)[source]

Generates a complete video file by iterating through time.

Return type:

None

show(dt, ax=None, **kwargs)[source]

Prepares the direct camera’s internal image for the given datetime. Consistent with DirectCamera, this method updates the internal state and returns None as no Matplotlib axes are involved.

Parameters:
  • dt (datetime) – The datetime for which to prepare the frame.

  • ax (Any) – Should be None. Included for PlottableInstrument compatibility.

  • **kwargs (Any) – Additional arguments passed to the direct_camera.show() method (e.g., brightness_adjust).

Return type:

None

start_video_output(output_path, fps, resolution)[source]

Initializes video writing to a file.

Parameters:
  • output_path (str) – Path to the output video file.

  • fps (int) – Frames per second for the video.

  • resolution (Tuple[int, int]) – Tuple (width, height) for the video frames.

Return type:

None