![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GL/Camera.h>
Abstraction layer to model both intrinsic (projection) and extrinsic (view) parameters of a camera showing a 3D scene. More...
Inheritance diagram for Camera:Abstraction layer to model both intrinsic (projection) and extrinsic (view) parameters of a camera showing a 3D scene.
This class was designed with both OpenGL and Computer Vision conventions in mind. It is mainly intended to facilitate setting up 3D views for OpenGL rendering. At the same time it uses terminology that is common popular in Computer Vision environments and provides an interface to easily transfer camera-calibration results into the camera setup used for rendering.
The extrinsic parameters describe the location and orientation of the camera in world space. In OpenGL terminology this is usually described by a view matrix that converts from world coordinates to camera coordinates. The intrinsic parameters describe the way how the scene is projected into a 2D image plane. Note that depending on the selected projection mode, a different set of intrinsic parameters are used to compile the final projection matrix.
Public Types | |
| enum class | Mode { Perspective , Orthographic } |
| Intrinsic camera mode/projection mode. More... | |
| enum | MatrixConvention { OpenGL , CV } |
| Enumeration to specify matrix conventions of pose (view) matrices. More... | |
Public Member Functions | |
| Camera () | |
| Creates a new camera object with default parameters. | |
| virtual void | configure (const Properties *p) override |
| Configure this object instance by de-serializing the given Properties. | |
| virtual void | configuration (Properties *p) const override |
| Serialize the current object configuration into the given Properties object. | |
Public Member Functions inherited from Configurable | |
| virtual void | configureDefaults () |
| Retrieve the properties of this object, replaces values with their defaults and sets it again. | |
| void | registerParameter (ParameterBase *param) |
| Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration(). | |
| void | unregisterParameter (const ParameterBase *param) |
| Remove the given Parameter or SubProperty from the list of registered parameters. | |
| Configurable (const Configurable &rhs) | |
| Configurable (Configurable &&rhs) noexcept | |
| Configurable & | operator= (const Configurable &) |
| Configurable & | operator= (Configurable &&) noexcept |
Static Public Member Functions | |
| static Camera | fromGlViewMatrix (const mat4 &viewMatrix) |
| Creates a new Camera object with the given GlView view matrix. | |
| static Camera | fromPose (const mat4 &T, MatrixConvention mc) |
| Creates a new Camera object with the given inverse OpenGL view matrix. | |
| static Camera | fromVectors (const vec3 &position, const vec3 &lookVector, const vec3 &upVector) |
| Creates a new Camera object with the given parameters. | |
Intrinsic Parameters | |
| Mode | mode () const |
| Returns the intrinsic camera mode. | |
| void | setMode (Mode value) |
| Sets the intrinsic camera mode. | |
| void | setIntrinsicMatrix (const mat3 &K, const vec2 &cameraSize) |
| Set the intrinsic parameters from a K-matrix commonly used in Computer Vision environments. | |
| mat3 | intrinisicMatrix (const vec2 &cameraSize) const |
| Get the intrinsic parameters from a K-matrix commonly used in Computer Vision environments. | |
| const vec2 & | principalPoint () const |
| Returns the principal point in normalized [0,1] viewport space, origin in top-left corner. | |
| void | setPrincipalPoint (const vec2 &value) |
| Sets the principal point in normalized [0,1] viewport space, origin in top-left corner. | |
| const vec2 & | focalLength () const |
| Returns the focal length in perspective mode in normalized [0,1] space. | |
| void | setFocalLength (const vec2 &value) |
| Sets the focal length in perspective mode in normalized [0,1] space. | |
| void | setFovY (double fov) |
| Set camera vertical field of view in degrees. | |
| double | fovY () const |
| Get camera vertical field of view in degrees. | |
| double | frustumHeight () const |
| Returns the view frustum height in mm in orthographic camera mode. | |
| void | setFrustumHeight (double value) |
| Sets the view frustum height in mm in orthographic camera mode. | |
| mat4 | openGLProjectionMatrix (double aspectRatio, double nearClipDistance, double farClipDistance) const |
| Compute the OpenGL projection matrix based on the camera's intrinsic parameters. | |
Extrinsic Parameters | |
| void | setPose (const mat4 &T, MatrixConvention mc) |
| Set pose as world to camera coordinate system transformation. | |
| mat4 | pose (MatrixConvention mc) const |
| Get pose as world to camera coordinate system transformation. | |
| void | setVectors (const vec3 &position, const vec3 &lookVector, const vec3 &upVector) |
| Set position, look vector and up vector at once. | |
| void | setLookAt (const vec3 &position, const vec3 ¢er, const vec3 &upVector) |
| Set eye position, look center and up vector at once. | |
| void | setLookAt (const Geometry::AlignedBox &worldBounds, const vec3 &lookVector, const vec3 &upVector, double boundsRatio=1.0) |
| Set camera position to look at the scene defined by worldBounds using the given lookVector and upVector. | |
| void | setPosition (const vec3 &value) |
| Sets the camera location in the world coordinate system. | |
| vec3 | position () const |
| Returns the camera location in the world coordinate system. | |
| vec3 | upVector () const |
| Returns the camera's up direction vector in the world coordinate system. | |
| vec3 | lookVector () const |
| Returns the camera's look direction vector in the world coordinate system. | |
| mat4 | openGLViewMatrix () const |
| Compute the OpenGL view matrix based on the camera's extrinsic parameters. | |
| mat4 | glViewMatrix () const |
| Get the GlView view matrix describing the camera's parameters. | |
Additional Inherited Members | |
Public Attributes inherited from Configurable | |
| Signal | signalParametersChanged |
Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted. | |
Protected Attributes inherited from Configurable | |
| std::vector< Param > | m_params |
| List of all registered Parameter and SubProperty instances. | |
|
strong |
| enum MatrixConvention |
|
static |
|
static |
Creates a new Camera object with the given inverse OpenGL view matrix.
| inverseViewMatrix | OpenGL view matrix from OpenGL camera coordinate system to world. |
|
static |
| void setIntrinsicMatrix | ( | const mat3 & | K, |
| const vec2 & | cameraSize ) |
Set the intrinsic parameters from a K-matrix commonly used in Computer Vision environments.
| mat3 intrinisicMatrix | ( | const vec2 & | cameraSize | ) | const |
Get the intrinsic parameters from a K-matrix commonly used in Computer Vision environments.
| void setFovY | ( | double | fov | ) |
Set camera vertical field of view in degrees.
| void setLookAt | ( | const Geometry::AlignedBox & | worldBounds, |
| const vec3 & | lookVector, | ||
| const vec3 & | upVector, | ||
| double | boundsRatio = 1.0 ) |
Set camera position to look at the scene defined by worldBounds using the given lookVector and upVector.
This function will automatically deduce the camera position based on the camera's intrinsic parameters so that the entire scene will be visible. The boundsRatio parameter controls how much margin is given around the bounds (1.0 would match the bounds exactly)
| mat4 openGLViewMatrix | ( | ) | const |
Compute the OpenGL view matrix based on the camera's extrinsic parameters.
| mat4 glViewMatrix | ( | ) | const |
Get the GlView view matrix describing the camera's parameters.
View matrix is from OpenGL camera coordinate system to world.
|
overridevirtual |
Configure this object instance by de-serializing the given Properties.
The default implementation will do so automatically for all registered Parameter and SubProperty instances.
Reimplemented from Configurable.
|
overridevirtual |
Serialize the current object configuration into the given Properties object.
The default implementation will do so automatically for all registered Parameter and SubProperty instances.
Reimplemented from Configurable.