Class Camera
Defined in File camera.hpp
Class Documentation
-
class Camera
This class implements a camera models, made up of intrinsic and extrinsic parameters (lib3d::Intrinsics & lib3d::Extrinsics).
The intrinsic parameters allow to model a perspective or parallel camera with or without distortion. The distortion models are implemented by OpenCV and supports radial, tangential and prism distortion. For more information see OpenCV-Website.
Example
Initialization of a perspecitve camera with no distortion (pinhole camera) and no rotation or translation use:
lib3d::Camera pinholeCamera(lib3d::Intrinsics( cv::Size(1920, 1080), // image size cv::Point2d(1273.38, 1231.75), // focal length cv::Point2d(960,540) // principal point ));
Public Functions
-
inline explicit Camera()
Default (zero initialization) constructor.
This will initialize the camera with no intrinsic and extrinsic parameters.
-
inline explicit Camera(const Intrinsics &intr)
Initialize camera with given intrinsic parameters.
- Parameters:
intr – [in] Intrinsic camera parameters.
-
inline explicit Camera(const Intrinsics &intr, const Extrinsics &extr)
Initialize camera with given intrinsic and extrinsic parameters.
- Parameters:
intr – [in] Intrinsic camera parameters.
extr – [in] Extrinsic camera parameters.
-
inline bool operator==(const Camera &rhs)
Comparison operator.
- Returns:
True, if the intrinsic, distortion and extrinsic parameters are equal.
-
inline bool operator!=(const Camera &rhs)
Comparison operator.
- Returns:
True, if the intrinsic, distortion and extrinsic parameters are NOT equal.
-
inline cv::Point2i projectWorld2Pixel(cv::Point3f worldPnt) const
Method to project a 3D world point into 2D pixel coordinates.
This will first transform the world point into local camera coordinates by applying
extrinsics.getRTMatrix(lib3d::Extrinsics::REF_2_LOCAL)
to the world point. Then it will perform a projection by getting the specific projeciton model from the instrinsic parameters. This will yield a point in image coordinates on the focal plance, centered in the principle point. This image point is then projected into pixel coordinates according to the calibration matrix \(\mathrm{K}\).This function will internally use the function
projectPoints
from OpenCV as this also considers the distortion parameters.Also see: https://docs.opencv.org/master/d9/d0c/group__calib3d.html
-
inline cv::Point2i projectWorld2Pixel(float worldPnt_x, float worldPnt_y, float worldPnt_z) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
-
inline cv::Point2i projectLocal2Pixel(cv::Point3f localPnt) const
Method to project a 3D point given in local coordinates of the camera into 2D pixel coordinates.
This is similar to projectWorld2Pixel, only that it omits the transformation with
extrinsics.getRTMatrix(lib3d::Extrinsics::REF_2_LOCAL)
. In this it es assumed that the local point is given in the coordinate system of the camera with the x-axis pointing to the right, the y-axis to the bottom and the z-axis to the viewing direction of the camera.This function will internally use the function
projectPoints
from OpenCV as this also considers the distortion parameters.Also see: https://docs.opencv.org/master/d9/d0c/group__calib3d.html
-
inline cv::Point2i projectLocal2Pixel(float localPnt_x, float localPnt_y, float localPnt_z) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Public Members
-
Intrinsics intrinsics
Intrinsic camera parameters.
-
Extrinsics extrinsics
Extrinsic camera parameters.
-
inline explicit Camera()