![]() |
SLProject
4.3.020
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
|
#include <SENSCalibration.h>
Public Types | |
| enum class | State { uncalibrated , calibrated , guessed } |
Public Member Functions | |
| SENSCalibration (const cv::Mat &cameraMat, const cv::Mat &distortion, cv::Size imageSize, cv::Size boardSize, float boardSquareMM, float reprojectionError, int numCaptured, const string &calibrationTime, int camSizeIndex, bool mirroredH, bool mirroredV, SENSCameraType camType, string computerInfos, int calibFlags, bool calcUndistortionMaps) | |
| creates a fully defined calibration More... | |
| SENSCalibration (const cv::Size &imageSize, float fovH, bool mirroredH, bool mirroredV, SENSCameraType type, string computerInfos) | |
| creates a guessed calibration using image size and fovV angle More... | |
| SENSCalibration (float sensorWMM, float sensorHMM, float focalLengthMM, const cv::Size &imageSize, bool mirroredH, bool mirroredV, SENSCameraType camType, string computerInfos) | |
| create a guessed calibration using sensor size, camera focal length and captured image size More... | |
| SENSCalibration (const cv::Mat &intrinsics, const cv::Size &imageSize, bool mirroredH, bool mirroredV, SENSCameraType camType, const string &computerInfos) | |
| create a calibration using a known camera matrix (intrinsics) without distortion parameters More... | |
| SENSCalibration (const string &calibDir, const string &calibFileName, bool calcUndistortionMaps) | |
| ??? More... | |
| ~SENSCalibration () | |
| destructor More... | |
| SENSCalibration (const SENSCalibration &other) | |
| copy constructor More... | |
| SENSCalibration & | operator= (const SENSCalibration &other) |
| copy assignment operator implicitly defined More... | |
| bool | save (const string &calibDir, const string &calibFileName) |
| Saves the camera calibration parameters to the config file. More... | |
| void | remap (cv::Mat &inDistorted, cv::Mat &outUndistorted) const |
| Undistorts the inDistorted image into the outUndistorted. More... | |
| void | adaptForNewResolution (const cv::Size &newSize, bool calcUndistortionMaps) |
| Adapts an already calibrated camera to a new resolution (cropping and scaling) More... | |
| void | buildUndistortionMaps () |
| Builds undistortion maps after calibration or loading. More... | |
| cv::Size | imageSize () const |
| cv::Size | imageSizeOriginal () const |
| float | imageAspectRatio () const |
| const cv::Mat & | cameraMat () const |
| const cv::Mat & | cameraMatUndistorted () const |
| const cv::Mat & | distortion () const |
| float | cameraFovVDeg () const |
| float | cameraFovHDeg () const |
| int | calibrationFlags () const |
| bool | calibFixPrincipalPoint () |
| bool | calibFixAspectRatio () |
| bool | calibZeroTangentDist () |
| bool | calibRationalModel () |
| bool | calibTiltedModel () |
| bool | calibThinPrismModel () |
| bool | isMirroredH () const |
| bool | isMirroredV () const |
| bool | undistortMapsValid () const |
| float | fx () const |
| float | fy () const |
| float | cx () const |
| float | cy () const |
| float | k1 () const |
| float | k2 () const |
| float | p1 () const |
| float | p2 () const |
| float | k3 () const |
| float | k4 () const |
| float | k5 () const |
| float | k6 () const |
| float | s1 () const |
| float | s2 () const |
| float | s3 () const |
| float | s4 () const |
| float | tauX () const |
| float | tauY () const |
| SENSCameraType | camType () const |
| State | state () const |
| int | numCapturedImgs () const |
| float | reprojectionError () const |
| cv::Size | boardSize () const |
| float | boardSquareMM () const |
| float | boardSquareM () const |
| string | calibrationTime () const |
| string | calibFileName () const |
| string | computerInfos () const |
| string | stateStr () const |
| void | calcCameraFovFromUndistortedCameraMat () |
| Calculates the vertical field of view angle in degrees. More... | |
| void | calculateUndistortedCameraMat () |
| Calculate a camera matrix that we use for the scene graph and for the reprojection of the undistored image. More... | |
Static Public Member Functions | |
| static void | getInnerAndOuterRectangles (const cv::Mat &cameraMatrix, const cv::Mat &distCoeffs, const cv::Mat &R, const cv::Mat &newCameraMatrix, const cv::Size &imgSize, cv::Rect_< float > &inner, cv::Rect_< float > &outer) |
| get inscribed and circumscribed rectangle More... | |
Private Member Functions | |
| bool | load (const string &calibDir, const string &calibFileName, bool calcUndistortionMaps) |
| Loads the calibration information from the config file. More... | |
| void | createFromGuessedFOV (int imageWidthPX, int imageHeightPX, float fovH) |
| Calculates camera intrinsics from a guessed FOV angle. More... | |
Private Attributes | |
| cv::Mat | _cameraMat |
| 3x3 Matrix for intrinsic camera matrix More... | |
| cv::Mat | _distortion |
| 4x1 Matrix for intrinsic distortion More... | |
| cv::Mat | _cameraMatOrig |
| 3x3 Matrix for intrinsic camera matrix (original from loading or calibration estimation) More... | |
| cv::Size | _imageSizeOrig |
| original image size (original from loading or calibration estimation) More... | |
| State | _state = State::uncalibrated |
| calibration state enumeration More... | |
| float | _cameraFovVDeg = 0.0f |
| Vertical field of view in degrees. More... | |
| float | _cameraFovHDeg = 0.0f |
| Horizontal field of view in degrees. More... | |
| string | _calibFileName |
| name for calibration file More... | |
| int | _calibFlags = 0 |
| OpenCV calibration flags. More... | |
| bool | _isMirroredH = false |
| Flag if image must be horizontally mirrored. More... | |
| bool | _isMirroredV = false |
| Flag if image must be vertically mirrored. More... | |
| int | _numCaptured = 0 |
| NO. of images captured. More... | |
| cv::Size | _boardSize |
| NO. of inner chessboard corners. More... | |
| float | _boardSquareMM = 20.f |
| Size of chessboard square in mm. More... | |
| float | _reprojectionError = -1.0f |
| Reprojection error after calibration. More... | |
| cv::Size | _imageSize |
| Input image size in pixels (after cropping) More... | |
| int | _camSizeIndex = -1 |
| The requested camera size index. More... | |
| cv::Mat | _undistortMapX |
| Undistortion float map in x-direction. More... | |
| cv::Mat | _undistortMapY |
| Undistortion float map in y-direction. More... | |
| cv::Mat | _cameraMatUndistorted |
| string | _calibrationTime = "-" |
| Time stamp string of calibration. More... | |
| string | _computerInfos |
| SENSCameraType | _camType = SENSCameraType::FRONTFACING |
Static Private Attributes | |
| static const int | _CALIBFILEVERSION = 6 |
| Global const file format version. More... | |
Definition at line 18 of file SENSCalibration.h.
|
strong |
Definition at line 21 of file SENSCalibration.h.
| SENSCalibration::SENSCalibration | ( | const cv::Mat & | cameraMat, |
| const cv::Mat & | distortion, | ||
| cv::Size | imageSize, | ||
| cv::Size | boardSize, | ||
| float | boardSquareMM, | ||
| float | reprojectionError, | ||
| int | numCaptured, | ||
| const string & | calibrationTime, | ||
| int | camSizeIndex, | ||
| bool | mirroredH, | ||
| bool | mirroredV, | ||
| SENSCameraType | camType, | ||
| string | computerInfos, | ||
| int | calibFlags, | ||
| bool | calcUndistortionMaps | ||
| ) |
creates a fully defined calibration
| SENSCalibration::SENSCalibration | ( | const cv::Size & | imageSize, |
| float | fovH, | ||
| bool | mirroredH, | ||
| bool | mirroredV, | ||
| SENSCameraType | type, | ||
| string | computerInfos | ||
| ) |
creates a guessed calibration using image size and fovV angle
| SENSCalibration::SENSCalibration | ( | float | sensorWMM, |
| float | sensorHMM, | ||
| float | focalLengthMM, | ||
| const cv::Size & | imageSize, | ||
| bool | mirroredH, | ||
| bool | mirroredV, | ||
| SENSCameraType | camType, | ||
| string | computerInfos | ||
| ) |
create a guessed calibration using sensor size, camera focal length and captured image size
| SENSCalibration::SENSCalibration | ( | const cv::Mat & | intrinsics, |
| const cv::Size & | imageSize, | ||
| bool | mirroredH, | ||
| bool | mirroredV, | ||
| SENSCameraType | camType, | ||
| const string & | computerInfos | ||
| ) |
create a calibration using a known camera matrix (intrinsics) without distortion parameters
| SENSCalibration::SENSCalibration | ( | const string & | calibDir, |
| const string & | calibFileName, | ||
| bool | calcUndistortionMaps | ||
| ) |
???
|
inline |
|
inline |
copy constructor
Definition at line 81 of file SENSCalibration.h.
| void SENSCalibration::adaptForNewResolution | ( | const cv::Size & | newSize, |
| bool | calcUndistortionMaps | ||
| ) |
Adapts an already calibrated camera to a new resolution (cropping and scaling)
Definition at line 443 of file SENSCalibration.cpp.
|
inline |
Definition at line 200 of file SENSCalibration.h.
|
inline |
Definition at line 202 of file SENSCalibration.h.
|
inline |
Definition at line 201 of file SENSCalibration.h.
| void SENSCalibration::buildUndistortionMaps | ( | ) |
Builds undistortion maps after calibration or loading.
Definition at line 350 of file SENSCalibration.cpp.
| void SENSCalibration::calcCameraFovFromUndistortedCameraMat | ( | ) |
Calculates the vertical field of view angle in degrees.
Definition at line 567 of file SENSCalibration.cpp.
| void SENSCalibration::calculateUndistortedCameraMat | ( | ) |
Calculate a camera matrix that we use for the scene graph and for the reprojection of the undistored image.
(The following is the algorithm from cv::getOptimalNewCameraMatrix and the code is here for understanding (it does the same))
Definition at line 501 of file SENSCalibration.cpp.
|
inline |
Definition at line 204 of file SENSCalibration.h.
|
inline |
Definition at line 168 of file SENSCalibration.h.
|
inline |
Definition at line 167 of file SENSCalibration.h.
|
inline |
Definition at line 170 of file SENSCalibration.h.
|
inline |
Definition at line 166 of file SENSCalibration.h.
|
inline |
Definition at line 203 of file SENSCalibration.h.
|
inline |
Definition at line 172 of file SENSCalibration.h.
|
inline |
Definition at line 171 of file SENSCalibration.h.
|
inline |
Definition at line 169 of file SENSCalibration.h.
|
inline |
Definition at line 164 of file SENSCalibration.h.
|
inline |
Definition at line 163 of file SENSCalibration.h.
|
inline |
Definition at line 160 of file SENSCalibration.h.
|
inline |
Definition at line 161 of file SENSCalibration.h.
|
inline |
Definition at line 196 of file SENSCalibration.h.
|
inline |
Definition at line 205 of file SENSCalibration.h.
|
private |
Calculates camera intrinsics from a guessed FOV angle.
Most laptop-, webcam- or mobile camera have a horizontal view angle or so called field of view (FOV) of around 65 degrees. From this parameter we can calculate the most important intrinsic parameter the focal length. All other parameters are set as if the lens would be perfect: No lens distortion and the view axis goes through the center of the image. If the focal length and sensor size is provided by the device we deduce the the fovV from it.
| imageWidthPX | image width in pixels |
| imageHeightPX | image height in pixels |
| fovH | average horizontal view angle in degrees |
Definition at line 412 of file SENSCalibration.cpp.
|
inline |
Definition at line 179 of file SENSCalibration.h.
|
inline |
Definition at line 180 of file SENSCalibration.h.
|
inline |
Definition at line 162 of file SENSCalibration.h.
|
inline |
Definition at line 177 of file SENSCalibration.h.
|
inline |
Definition at line 178 of file SENSCalibration.h.
|
static |
|
inline |
Definition at line 159 of file SENSCalibration.h.
|
inline |
Definition at line 156 of file SENSCalibration.h.
|
inline |
Definition at line 157 of file SENSCalibration.h.
|
inline |
Definition at line 173 of file SENSCalibration.h.
|
inline |
Definition at line 174 of file SENSCalibration.h.
|
inline |
Definition at line 181 of file SENSCalibration.h.
|
inline |
Definition at line 182 of file SENSCalibration.h.
|
inline |
Definition at line 185 of file SENSCalibration.h.
|
inline |
Definition at line 186 of file SENSCalibration.h.
|
inline |
Definition at line 187 of file SENSCalibration.h.
|
inline |
Definition at line 188 of file SENSCalibration.h.
|
private |
Loads the calibration information from the config file.
Added a flag to disable calculation of undistortion maps because this may take a lot of time for big images on mobile devices
Definition at line 151 of file SENSCalibration.cpp.
|
inline |
Definition at line 198 of file SENSCalibration.h.
|
inline |
|
inline |
Definition at line 183 of file SENSCalibration.h.
|
inline |
Definition at line 184 of file SENSCalibration.h.
| void SENSCalibration::remap | ( | cv::Mat & | inDistorted, |
| cv::Mat & | outUndistorted | ||
| ) | const |
Undistorts the inDistorted image into the outUndistorted.
Definition at line 383 of file SENSCalibration.cpp.
|
inline |
Definition at line 199 of file SENSCalibration.h.
|
inline |
Definition at line 189 of file SENSCalibration.h.
|
inline |
Definition at line 190 of file SENSCalibration.h.
|
inline |
Definition at line 191 of file SENSCalibration.h.
|
inline |
Definition at line 192 of file SENSCalibration.h.
| bool SENSCalibration::save | ( | const string & | calibDir, |
| const string & | calibFileName | ||
| ) |
Saves the camera calibration parameters to the config file.
Definition at line 238 of file SENSCalibration.cpp.
|
inline |
Definition at line 197 of file SENSCalibration.h.
|
inline |
Definition at line 206 of file SENSCalibration.h.
|
inline |
Definition at line 193 of file SENSCalibration.h.
|
inline |
Definition at line 194 of file SENSCalibration.h.
|
inline |
Definition at line 175 of file SENSCalibration.h.
|
private |
NO. of inner chessboard corners.
Definition at line 248 of file SENSCalibration.h.
|
private |
Size of chessboard square in mm.
Definition at line 249 of file SENSCalibration.h.
|
private |
name for calibration file
Definition at line 239 of file SENSCalibration.h.
|
staticprivate |
Global const file format version.
Increase the _CALIBFILEVERSION each time you change the file format.
Definition at line 272 of file SENSCalibration.h.
|
private |
OpenCV calibration flags.
Definition at line 240 of file SENSCalibration.h.
|
private |
Time stamp string of calibration.
Definition at line 268 of file SENSCalibration.h.
|
private |
Horizontal field of view in degrees.
Definition at line 238 of file SENSCalibration.h.
|
private |
Vertical field of view in degrees.
Definition at line 237 of file SENSCalibration.h.
|
private |
3x3 Matrix for intrinsic camera matrix
Definition at line 228 of file SENSCalibration.h.
|
private |
3x3 Matrix for intrinsic camera matrix (original from loading or calibration estimation)
Definition at line 233 of file SENSCalibration.h.
|
private |
Definition at line 267 of file SENSCalibration.h.
|
private |
The requested camera size index.
Definition at line 252 of file SENSCalibration.h.
|
private |
Definition at line 270 of file SENSCalibration.h.
|
private |
Definition at line 269 of file SENSCalibration.h.
|
private |
4x1 Matrix for intrinsic distortion
Definition at line 229 of file SENSCalibration.h.
|
private |
Input image size in pixels (after cropping)
Definition at line 251 of file SENSCalibration.h.
|
private |
original image size (original from loading or calibration estimation)
Definition at line 234 of file SENSCalibration.h.
|
private |
Flag if image must be horizontally mirrored.
Definition at line 242 of file SENSCalibration.h.
|
private |
Flag if image must be vertically mirrored.
Definition at line 244 of file SENSCalibration.h.
|
private |
NO. of images captured.
Definition at line 247 of file SENSCalibration.h.
|
private |
Reprojection error after calibration.
Definition at line 250 of file SENSCalibration.h.
|
private |
calibration state enumeration
Definition at line 236 of file SENSCalibration.h.
|
private |
Undistortion float map in x-direction.
Definition at line 254 of file SENSCalibration.h.
|
private |
Undistortion float map in y-direction.
Definition at line 255 of file SENSCalibration.h.