Class Camera¶
Defined in File camera.h
Inheritance Relationships¶
Base Type¶
public aslam::Sensor
(Class Sensor)
Derived Types¶
public aslam::Cloneable< Camera, Camera3DLidar >
(Template Class Cloneable)public aslam::Cloneable< Camera, PinholeCamera >
(Template Class Cloneable)public aslam::Cloneable< Camera, UnifiedProjectionCamera >
(Template Class Cloneable)
Class Documentation¶
-
class aslam::Camera : public aslam::Sensor¶
The base camera class provides methods to project/backproject euclidean and homogeneous points.
The actual projection is implemented in the derived classes for euclidean coordinates only; homogeneous coordinates are support by a conversion. The intrinsic parameters are documented in the specialized camera classes.
Subclassed by aslam::Cloneable< Camera, Camera3DLidar >, aslam::Cloneable< Camera, PinholeCamera >, aslam::Cloneable< Camera, UnifiedProjectionCamera >
Constructors/destructors and operators
-
virtual ~Camera() = default¶
-
inline std::ostream &operator<<(std::ostream &out)¶
Convenience function to print the state using streams.
-
virtual aslam::Camera *clone() const = 0¶
Clones the camera instance and returns a pointer to the copy.
-
inline virtual uint8_t getSensorType() const override¶
Get sensor type as an integer or as a string.
-
inline virtual std::string getSensorTypeString() const override¶
-
Camera() = delete¶
-
Camera(const Eigen::VectorXd &intrinsics, aslam::Distortion::UniquePtr &distortion, const uint32_t image_width, const uint32_t image_height, Type camera_type)¶
Camera base constructor with distortion.
- Parameters
intrinsics – [in] Vector containing the intrinsic parameters.
distortion – [in] unique_ptr to the distortion model
image_width – [in] Image width in pixels.
image_height – [in] Image height in pixels.
camera_type – [in] CameraType enum value with information which camera model is used by the derived class.
-
Camera(const Eigen::VectorXd &intrinsics, const uint32_t image_width, const uint32_t image_height, Type camera_type)¶
Camera base constructor without distortion.
- Parameters
intrinsics – [in] Vector containing the intrinsic parameters.
image_width – [in] Image width in pixels.
image_height – [in] Image height in pixels.
camera_type – [in] CameraType enum value with information which camera model is used by the derived class.
Information about the camera
-
inline uint32_t imageWidth() const¶
The width of the image in pixels.
-
inline uint32_t imageHeight() const¶
The height of the image in pixels.
-
inline void setImageWidth(uint32_t image_width)¶
Set the width of the image in pixels.
-
inline void setImageHeight(uint32_t image_height)¶
Set the height of the image in pixels.
-
virtual void printParameters(std::ostream &out, const std::string &text) const¶
Print the internal parameters of the camera in a human-readable form Print to the ostream that is passed in.
The text is extra text used by the calling function to distinguish cameras.
-
virtual int getParameterSize() const = 0¶
The number of intrinsic parameters.
Methods to project and back-project euclidean points
-
const ProjectionResult project3(const Eigen::Ref<const Eigen::Vector3d> &point_3d, Eigen::Vector2d *out_keypoint) const¶
Projects a euclidean point to a 2d image measurement.
Applies the projection (& distortion) models to the point.
- Parameters
point_3d – [in] The point in euclidean coordinates.
out_keypoint – [out] The keypoint in image coordinates.
- Returns
Contains information about the success of the projection. Check ProjectionResult for more information.
-
const ProjectionResult project3(const Eigen::Ref<const Eigen::Vector3d> &point_3d, Eigen::Vector2d *out_keypoint, Eigen::Matrix<double, 2, 3> *out_jacobian) const¶
Projects a euclidean point to a 2d image measurement.
Applies the projection (& distortion) models to the po int.
- Parameters
point_3d – [in] The point in euclidean coordinates.
out_keypoint – [out] The keypoint in image coordinates.
out_jacobian – [out] The Jacobian wrt. to changes in the euclidean point.
- Returns
Contains information about the success of the projection. Check ProjectionResult for more information.
-
virtual void project3Vectorized(const Eigen::Ref<const Eigen::Matrix3Xd> &points_3d, Eigen::Matrix2Xd *out_keypoints, std::vector<ProjectionResult> *out_results) const¶
Projects a matrix of euclidean points to 2d image measurements.
Applies the projection (& distortion) models to the points.
This vanilla version just repeatedly calls backProject3. Camera implementers are encouraged to override for efficiency.
- Parameters
point_3d – [in] The point in euclidean coordinates.
out_keypoints – [out] The keypoint in image coordinates.
out_results – [out] Contains information about the success of the projections. Check ProjectionResult for more information.
-
virtual bool backProject3(const Eigen::Ref<const Eigen::Vector2d> &keypoint, Eigen::Vector3d *out_point_3d) const = 0¶
Compute the 3d bearing vector in euclidean coordinates given a keypoint in image coordinates.
Uses the projection (& distortion) models. The result might be in normalized image plane for some camera implementations but not for the general case.
- Parameters
keypoint – [in] Keypoint in image coordinates.
out_point_3d – [out] Bearing vector in euclidean coordinates
- Returns
Was the projection successful?
-
virtual void backProject3Vectorized(const Eigen::Ref<const Eigen::Matrix2Xd> &keypoints, Eigen::Matrix3Xd *out_points_3d, std::vector<unsigned char> *out_success) const¶
Compute the 3d bearing vectors in euclidean coordinates given a list of keypoints in image coordinates.
Uses the projection (& distortion) models.
This vanilla version just repeatedly calls backProject3. Camera implementers are encouraged to override for efficiency. TODO(schneith): implement efficient backProject3Vectorized
- Parameters
keypoints – [in] Keypoints in image coordinates.
out_point_3ds – [out] Bearing vectors in euclidean coordinates (with z=1 -> non-normalized).
out_success – [out] Were the projections successful?
Methods to project and back-project homogeneous points
-
const ProjectionResult project4(const Eigen::Ref<const Eigen::Vector4d> &point_4d, Eigen::Vector2d *out_keypoint) const¶
Projects a homogeneous point to a 2d image measurement.
Applies the projection (& distortion) models to the point.
- Parameters
point_4d – [in] The point in homogeneous coordinates.
out_keypoint – [out] The keypoint in image coordinates.
- Returns
Contains information about the success of the projection. Check ProjectionResult for more information.
-
const ProjectionResult project4(const Eigen::Ref<const Eigen::Vector4d> &point_4d, Eigen::Vector2d *out_keypoint, Eigen::Matrix<double, 2, 4> *out_jacobian) const¶
Projects a euclidean point to a 2d image measurement.
Applies the projection (& distortion) models to the point.
- Parameters
point_4d – [in] The point in homogeneous coordinates.
out_keypoint – [out] The keypoint in image coordinates.
out_jacobian – [out] The Jacobian wrt. to changes in the homogeneous point.
- Returns
Contains information about the success of the projection. Check ProjectionResult for more information.
-
bool backProject4(const Eigen::Ref<const Eigen::Vector2d> &keypoint, Eigen::Vector4d *out_point_4d) const¶
Compute the 3d bearing vector in homogeneous coordinates given a keypoint in image coordinates.
Uses the projection (& distortion) models.
- Parameters
keypoint – [in] Keypoint in image coordinates.
out_point_3d – [out] Bearing vector in homogeneous coordinates.
- Returns
Was the projection successful?
Functional methods to project and back-project points
-
const ProjectionResult project3Functional(const Eigen::Ref<const Eigen::Vector3d> &point_3d, const Eigen::VectorXd *intrinsics_external, const Eigen::VectorXd *distortion_coefficients_external, Eigen::Vector2d *out_keypoint) const¶
This function projects a point into the image using the intrinsic parameters that are passed in as arguments.
If any of the Jacobians are nonnull, they should be filled in with the Jacobian with respect to small changes in the argument.
- Parameters
point_3d – [in] The point in euclidean coordinates.
intrinsics_external – [in] External intrinsic parameter vector. NOTE: If nullptr, use internal intrinsic parameters.
distortion_coefficients_external – [in] External distortion parameter vector. Parameter is ignored is no distortion is active. NOTE: If nullptr, use internal distortion parameters.
out_keypoint – [out] The keypoint in image coordinates.
- Returns
Contains information about the success of the projection. Check ProjectionResult for more information.
-
virtual const ProjectionResult project3Functional(const Eigen::Ref<const Eigen::Vector3d> &point_3d, const Eigen::VectorXd *intrinsics_external, const Eigen::VectorXd *distortion_coefficients_external, Eigen::Vector2d *out_keypoint, Eigen::Matrix<double, 2, 3> *out_jacobian_point, Eigen::Matrix<double, 2, Eigen::Dynamic> *out_jacobian_intrinsics, Eigen::Matrix<double, 2, Eigen::Dynamic> *out_jacobian_distortion) const = 0¶
This function projects a point into the image using the intrinsic parameters that are passed in as arguments.
If any of the Jacobians are nonnull, they should be filled in with the Jacobian with respect to small changes in the argument.
- Parameters
point_3d – [in] The point in euclidean coordinates.
intrinsics_external – [in] External intrinsic parameter vector. NOTE: If nullptr, use internal intrinsic parameters.
distortion_coefficients_external – [in] External distortion parameter vector. Parameter is ignored is no distortion is active. NOTE: If nullptr, use internal distortion parameters.
out_keypoint – [out] The keypoint in image coordinates.
out_jacobian_point – [out] The Jacobian wrt. to changes in the euclidean point. nullptr: calculation is skipped.
out_jacobian_intrinsics – [out] The Jacobian wrt. to changes in the intrinsics. nullptr: calculation is skipped.
out_jacobian_distortion – [out] The Jacobian wrt. to changes in the distortion parameters. nullptr: calculation is skipped.
- Returns
Contains information about the success of the projection. Check ProjectionResult for more information.
Methods to support rolling shutter cameras
-
inline uint64_t getLineDelayNanoSeconds() const¶
Return the temporal offset of a rolling shutter camera.
Global shutter cameras return zero.
- Returns
Line delay in nano seconds.
-
inline void setLineDelayNanoSeconds(uint64_t line_delay_nano_seconds)¶
Set the temporal offset of a rolling shutter camera.
- Parameters
line_delay_nano_seconds – [in] Line delay in nano seconds.
-
inline virtual int64_t rollingShutterDelayNanoSeconds(const Eigen::Vector2d &keypoint) const¶
The amount of time elapsed between the first row of the image and the keypoint.
For a global shutter camera, this can return Duration(0).
- Parameters
keypoint – [in] Keypoint to which the delay should be calculated.
- Returns
Time elapsed between the first row of the image and the keypoint in nanoseconds.
-
inline virtual int64_t maxRollingShutterDelayNanoSeconds() const¶
The amount of time elapsed between the first row of the image and the last row of the image.
For a global shutter camera, this can return 0.
-
inline virtual uint32_t getNumberOfLines() const¶
returns the number of lines, this is either the number of columns or rows or 1 in case of a global shutter camera.
-
inline virtual LineDelayMode getLineDelayMode() const¶
Returns which orientation the rolling shutter effect is occuring.
Methods to support compressed images.
-
inline bool hasCompressedImages() const¶
Holds whether this camera receives compressed images.
- Returns
Returns true for compressed images, false otherwise
-
inline void setCompressedImages(const bool is_compressed)¶
Set the whether this camera has compressed images.
- Parameters
is_compressed – [in] Compressed images.
Methods to test validity and visibility
-
bool isProjectable3(const Eigen::Ref<const Eigen::Vector3d> &point) const¶
Can the projection function be run on this point? This doesn’t test if the projected point is visible, only if the projection function can be run without numerical errors or singularities.
-
bool isProjectable4(const Eigen::Ref<const Eigen::Vector4d> &point) const¶
Can the projection function be run on this point? This doesn’t test if the projected point is visible, only if the projection function can be run without numerical errors or singularities.
-
template<typename DerivedKeyPoint>
bool isKeypointVisible(const Eigen::MatrixBase<DerivedKeyPoint> &keypoint) const¶ Return if a given keypoint is inside the imaging box of the camera.
-
template<typename DerivedKeyPoint>
bool isKeypointVisibleWithMargin(const Eigen::MatrixBase<DerivedKeyPoint> &keypoint, typename DerivedKeyPoint::Scalar margin) const¶ Return if a given keypoint is within the specified margin to the boundary of the imaging box of the camera.
Methods to support unit testing.
-
virtual Eigen::Vector2d createRandomKeypoint() const = 0¶
Creates a random valid keypoint.
-
virtual Eigen::Vector3d createRandomVisiblePoint(double depth) const = 0¶
Creates a random visible point.
Negative depth means random between 0 and 100 meters.
Methods to interface the underlying distortion model.
-
inline aslam::Distortion *getDistortionMutable()¶
Returns a pointer to the underlying distortion object.
-
inline const aslam::Distortion &getDistortion() const¶
Returns the underlying distortion object.
-
inline void setDistortion(aslam::Distortion::UniquePtr &distortion)¶
Set the distortion model.
-
inline bool hasDistortion() const¶
Is a distortion model set for this camera.
-
inline void removeDistortion()¶
Remove the distortion model from this camera.
Methods to access the intrinsic parameters.
-
inline const Eigen::VectorXd &getParameters() const¶
Get the intrinsic parameters (const).
-
inline double *getParametersMutable()¶
Get the intrinsic parameters.
-
inline void setParameters(const Eigen::VectorXd ¶ms)¶
Set the intrinsic parameters.
Parameters are documented in the specialized camera classes.
-
virtual bool intrinsicsValid(const Eigen::VectorXd &intrinsics) const = 0¶
Function to check whether the given intrinsic parameters are valid for this model.
Methods to access the mask.
-
void setMask(const cv::Mat &mask)¶
Set the mask.
Masks must be the same size as the image and they follow the same convention as OpenCV: 0 == masked, nonzero == valid.
-
const cv::Mat &getMask() const¶
Get the mask.
-
void clearMask()¶
Clear the mask.
-
bool hasMask() const¶
Does the camera have a mask?
-
inline bool isMasked(const Eigen::Ref<const Eigen::Vector2d> &keypoint) const¶
Check if the keypoint is masked.
Factory Methods
-
template<typename DerivedCamera, typename DerivedDistortion>
static DerivedCamera::Ptr construct(const Eigen::VectorXd &intrinsics, uint32_t imageWidth, uint32_t imageHeight, const Eigen::VectorXd &distortionParameters)¶ A factory function to create a derived class camera.
This function takes a vectors of intrinsics and distortion parameters and produces a camera.
- Parameters
intrinsics – [in] A vector of projection intrinsic parameters.
imageWidth – [in] The width of the image associated with this camera.
imageHeight – [in] The height of the image associated with this camera.
distortionParameters – [in] The parameters of the distortion object.
- Returns
A new camera based on the template types.
Public Types
Protected Attributes
-
uint64_t line_delay_nanoseconds_¶
The delay per scanline for a rolling shutter camera in nanoseconds.
-
uint32_t image_width_¶
The width of the image.
-
uint32_t image_height_¶
The height of the image.
-
cv::Mat_<uint8_t> mask_¶
The image mask.
-
bool is_compressed_¶
Has compressed images.
-
Eigen::VectorXd intrinsics_¶
Parameter vector for the intrinsic parameters of the model.
-
aslam::Distortion::UniquePtr distortion_¶
The distortion for this camera.
-
virtual ~Camera() = default¶