Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
Loading...
Searching...
No Matches
cam::CameraParams Class Reference

Represents a set of intrinsic camera parameters. More...

#include <CameraParams.h>

Public Member Functions

 CameraParams ()
 Constructs a default or empty set of camera parameters.
 
 CameraParams (const cv::Mat &camera_matrix, const cv::Mat &dist_coeff, cv::Size image_size=cv::Size(640, 480))
 Constructs a set of camera parameters with the given camera matrix, distortion coefficients, and image size.
 
 CameraParams (const CameraParams &other)
 Copy constructor.
 
bool empty () const
 
cv::Mat getCameraMatrix () const
 Gets the camera matrix associated with this set of camera parameters.
 
cv::Mat getDistCoeff () const
 Gets the distortion coefficients (as a column vector) associated with this set of camera parameters.
 
cv::Size getImageSize () const
 Gets the image size this set of intrinsic parameters was calibrated for.
 
std::vector< double > getIntrinsicList ()
 Gets the camera intrinsics as a 1d list.
 
CameraParamsoperator= (const CameraParams &other)
 Define a copy assignment operator.
 
void readFromFileNode (const cv::FileNode &file_node)
 Reads the data for this CameraParams object from the given cv::FileNode object.
 
void writeToFileStorage (cv::FileStorage &file_storage) const
 Writes the data for this CameraParams object to the given cv::FileStorage object.
 

Detailed Description

Represents a set of intrinsic camera parameters.

Camera parameters (also called "intrinsic parameters") are obtained from camera calibration and are unique to and constant for every camera. They define how the camera projects a 3D space onto a 2D image plane.

Each set of CameraParams contains a camera matrix which defines how points in 3D space are linearly projected to the 2D image plane of the camera, and a set of distortion coefficients which can be used to correct for radial distortion in the image. The projection is linear which means that projected points are unique only up to scaling.

Warning
Note that camera parameters are different for different resolutions of the camera! It is often not enough to simply scale the image centers/focal lengths for different resolutions because many cameras have different fields of view (and therefore different projections/distortion) at different resolutions. For this reason, a CameraParams object has an associated cv::Size which contains the image size the parameters are valid for.

Constructor & Destructor Documentation

◆ CameraParams() [1/3]

cam::CameraParams::CameraParams ( )

Constructs a default or empty set of camera parameters.

Warning
Empty sets of camera parameters are not suitable for actual use! Check to make sure they are non-empty with empty().

◆ CameraParams() [2/3]

cam::CameraParams::CameraParams ( const cv::Mat & camera_matrix,
const cv::Mat & dist_coeff,
cv::Size image_size = cv::Size(640, 480) )

Constructs a set of camera parameters with the given camera matrix, distortion coefficients, and image size.

Parameters
camera_matrixA 3x3 matrix defining the projection of the camera.
dist_coeffA set of distortion coefficients defining the lens distortion of the camera. Must be a 1xN or Nx1 matrix where N is the number of coefficients. N must be 4, 5, 8, 12, or 14.
image_sizeThe size of the image the parameters are calibrated for. Defaults to 640x480 as this is the default resolution of many webcams.

◆ CameraParams() [3/3]

cam::CameraParams::CameraParams ( const CameraParams & other)

Copy constructor.

Constructs a set of camera parameters by copying another. Underlying data like the camera matrix and distortion coefficients are actually copied, so the copy may be modified without affecting the original.

Member Function Documentation

◆ readFromFileNode()

void cam::CameraParams::readFromFileNode ( const cv::FileNode & file_node)

Reads the data for this CameraParams object from the given cv::FileNode object.

Used for serialization - you should not need to call this method directly but should instead use the >> operator on a cv::FileNode object.

◆ writeToFileStorage()

void cam::CameraParams::writeToFileStorage ( cv::FileStorage & file_storage) const

Writes the data for this CameraParams object to the given cv::FileStorage object.

Used for serialization - you should not need to call this method directly but should instead use the << operator on a cv::FileStorage object.


The documentation for this class was generated from the following files: