Camera

class sonic.Camera
Constructor Summary
Camera(varargin)

Instantiates a model for a framing camera. Depending on the arguments, either invokes constructFromFOV() or constructFromK() to complete the model instantiation. See those methods below for details.

Inputs:
  • varargin: see constructFromFOV() and constructFromK().

Outputs:
  • obj (sonic.Camera): Camera object, containing camera intrinsics and a distortion model.

Last revised: 03/15/24 Last author: Michael Krause

Property Summary
K
Kinv
alpha
d_x
d_y
dist_model
hfov_RAD
ifov_h_RAD
ifov_v_RAD
u_p
v_p
vfov_RAD
Method Summary
constructFromFOV(fov, fov_type, direction, res, dist_model)

Creates a model for a framing camera using information about the camera’s FOV or instantaneous FOV, as well as sensor resolution. Also consumes a distortion model. Note that x/y directions here coorespond with the canonical camera model, i.e.: +z along boresight, +x to the right looking out of the camera, +y down looking out of the camera. As well, u/v cooresponds to x/y directions, but is centered in the top-left of the image.

NOTE: Cannot directly call this method. Will be invoked based on the appropriate arguments being passed into the constructor.

NOTE: When constructing a camera model with this method, square pixels and no shear are assumed. If this is not the case, construct the camera model directly from the camera intrinsics.

Inputs:
  • fov (1x1 double): Field-of-view or IFOV, in radians. In either case, these are full-angle values.

  • fov_type (1x1 string): String specifying whether the previous argument was an FOV (‘fov’) or IFOV (‘ifov’).

  • direction (1x1 string): String indicating the direction of the aforementioned FOV/IFOV: ‘h’ for horizontal FOV/IFOV, and ‘v’ for vertical FOV/IFOV.

  • res (2 double): Resolution of the sensor, specified as [# of rows, # of cols]

  • dist_model (1x1 sonic.DistortionModel): Distortion model used to transform projected points prior to being passed through the camera intrinsics.

Outputs:
  • obj (sonic.Camera): Camera object, containing camera intrinsics and a distortion model.

Last revised: 03/15/24 Last author: Michael Krause

constructFromK(d_x, d_y, alpha, u_p, v_p, dist_model)

Creates a model for a framing camera using elements of the camera calibration matrix. Also consumes a distortion model. Note that x/y directions here coorespond with the canonical camera model, i.e.: +z along boresight, +x to the right looking out of the camera, +y down looking out of the camera. As well, u/v cooresponds to x/y directions, but is centered in the top-left of the image.

NOTE: Cannot directly call this method. Will be invoked based on the appropriate arguments being passed into the constructor.

Inputs:
  • d_x (1x1 double): Focal length/pixel pitch, x direction

  • d_y (1x1 double): Focal length/pixel pitch, y direction

  • alpha (1x1 double): Pixel shear

  • u_p (1x1 double): Center point, u coordinates (pixels)

  • v_p (1x1 double): Center point, v coordinates (pixels)

  • dist_model (1x1 sonic.DistortionModel): Distortion model used to transform projected points prior to being passed through the camera intrinsics.

Outputs:
  • obj (sonic.Camera): Camera object, containing camera intrinsics and a distortion model.

Last revised: 03/15/24 Last author: Michael Krause

synthImage(to_proj, attitude, velocity, opts)

Given 3D geometry (currently only supports 3D points, i.e., Points3 or PointsS2), projects this geometry into a synthetic image per the camera model.

Inputs:
  • obj (1x1 sonic.Camera): Camera object, containing camera intrinsics and a distortion model.

  • to_proj (1x1 sonic.Points3 or sonic.PointsS2): Points to project into an image.

  • attitude (1x1 sonic.Attitude): Attitude of the object relative to the camera

  • velocity (3x1 double): OPTIONAL: Velocity of the camera in the inertial frame. Defaults to zero if not supplied.

  • opts.projectBehindCamera (1x1 logical): OPTIONAL: defaults to false. If true, also projects points that lie behind the camera. See sonic.Project for more details.

  • opts.cropFOV (2 double or []): OPTIONAL: If specified, allows the user to override the FOV of the camera when cropping the projected image. Can specify as a 2 element vector, [hfov_RAD, vfov_RAD], or [] to not crop at all. Defaults to the HFOV/VFOV of the camera.

Outputs:
  • proj_px (1x1 sonic.Points2): 2D points lying in the image plane, in pixel coordinates. Represents the projection of the provided points per the camera model.

  • proj_map (1xn logical): Given that to_proj contains n points, this is 1-by-n logical vector containing m true values (where m points were successfully projected into the resultant image), corresponding to each index of a successful projection.

Last revised: 03/15/24 Last author: Michael Krause