![]() |
ImFusion SDK 4.3
|
Collection of functions dealing with projective geometry. More...
Collection of functions dealing with projective geometry.
Functions | |
| void | normalizePoints2D (const std::vector< vec2 > &ptsIn, std::vector< vec2 > &ptsOut, mat3 *T=0) |
| Normalize points so that their centroid is at the origin and their average distance from the origin is sqrt(2) | |
| void | normalizePoints2D (const std::vector< vec3 > &ptsIn, std::vector< vec3 > &ptsOut, mat3 *T=0) |
| Normalize points so that their centroid is at the origin and their average distance from the origin is sqrt(2) | |
| void | normalizePoints3D (const std::vector< vec4 > &ptsIn, std::vector< vec4 > &ptsOut, mat4 *T=0) |
| Normalize points so that their centroid is at the origin and their average distance from the origin is sqrt(2) | |
| bool | computeHomography2D (const std::vector< vec3 > &x1, const std::vector< vec3 > &x2, mat3 &H) |
| Compute homography H so that H*x1 = x2. x1 and x2 are vectors of points in homogeneous coordinates. | |
| void | computeProjectionMatrix (const vec3 &C, const vec3 &p1, const vec3 &p2, const vec3 &p3, const vec3 &p4, int w, int h, mat3 &K, mat3 &R, vec3 &t) |
| Compute projection matrix for source-detector geometry p1, p2, p3 and p4 are the detector corner points in the order top-left, top-right, bottom-right and bottom-left as seen from the source. | |
| bool | computeProjectionMatrix (const std::vector< vec3 > &X, const std::vector< vec2 > &x, mat34 &P1, mat34 &P2, bool &P2IsAPossibleSolution) |
| Estimate projection matrix from point correspondences. | |
| bool | computeCameraPose (const std::vector< vec3 > &X, const std::vector< vec2 > &x, const mat3 &K, const vec5 &distCoeffs, mat4 &T, double *mre=nullptr, std::vector< vec2 > *reprojectedPoints=nullptr) |
| Estimate camera pose (i.e. | |
| bool | computeProjectionMatrix (const std::vector< vec3 > &X, const std::vector< vec2 > &x, mat34 &P) |
| Compute projection matrix from point correspondences. | |
| bool | computeProjective3D (const std::vector< vec4 > &x1, const std::vector< vec4 > &x2, mat4 &P) |
| Compute general 3D projective transformation so that P*x1 = x2. | |
| bool | computeAffine3D (const std::vector< vec4 > &x1, const std::vector< vec4 > &x2, mat4 &T) |
| Compute 3D affine transformation so that T*x1 = x2. | |
| void | normalizePoints (const std::vector< vec2 > &pts, mat3 &T) |
| Compute normalizing transformation for 2D points so that they are centered on the origin and the average distance from the origin is sqrt(2) | |
| void | normalizePoints (const std::vector< vec3 > &pts, mat4 &T) |
| Compute normalizing transformation for 3D points so that they are centered on the origin and the average distance from the origin is sqrt(2) | |
| double | computeReprojectionError (const mat34 &P, const std::vector< vec3 > &X, const std::vector< vec2 > &x) |
| Compute reprojection error. | |
| double | computeReprojectionError (const mat3 &K, const std::vector< mat3 > &R, const std::vector< vec3 > &t, const std::vector< vec3 > &X, const std::vector< std::vector< vec2 > > &x, const Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &vis) |
| Compute reprojection error over a sequence. | |
| double | triangulatePoint (const std::vector< vec2 > &x, const std::vector< mat34 > &P, vec3 &X, bool nonLinearRefinement=true) |
| Triangulate point given image measurements and projection matrices. | |
| void | convertComputerVisionToOpenGlProjectionMatrix (const mat3 &K, const mat3 &R, const vec3 &t, int width, int height, double near, double far, mat4 &PM, mat4 &MV, bool flipImageYAxis=false) |
| Convert a projection matrix to OpenGL representation from OpenCV convention In OpenCV convention the y-axis is flipped compared to OpenGL, and pixel coordinates are used. | |
| void | convertOpenGlToComputerVisionProjectionMatrix (const mat4 &PM, int width, int height, mat34 &P) |
| Convert an OpenGL projection matrix to computer vision representation. | |
| void | decomposeProjectionMatrix (const mat34 &P, mat3 &K, mat3 &R, vec3 &t, bool checkOpenCVConvention=true) |
| Decompose projection matrix into K, R and t. | |
| vec3 | reproject (const mat4 &projMat, const vec2 &imgPoint2D, double physicalWidth, vec3 &sourceOut3D, vec3 &imgOut3D, vec3 &zDirOut, double &fac) |
| Reprojects a point on the image plane using an OpenGL projection matrix. | |
| vec3 | reproject (const mat4 &projMat, const vec2 &imgPoint2D, double physicalWidth, vec3 &sourceOut3D, vec3 &imgOut3D) |
| Reprojects a point on the image plane using an OpenGL projection matrix. | |
| void | unproject (const mat3 &invK, double dist, const vec2 &pt2d, vec3 &pt3d) |
| Unprojects a point on the image plane, where dist corresponds to the distance of pt3d from the xy plane and invK is the inverse calibration matrix of the camera. | |
| void | projectPoint (const mat34 &P, vec4 &pt3d, vec3 &pt2d, const bool normalize=true) |
| Projects a 3d point to 2d using a 3x4 projection matrix. | |
| void | projectPoint (const mat34 &P, vec3 &pt3d, vec3 &pt2d, const bool normalize=true) |
| Projects an inhomogenous 3d point to 2d using a 3x4 projection matrix. | |
| std::vector< vec2 > | projectPoints (const std::vector< vec3 > &pts3d, const mat3 &K, const mat3 &R, const vec3 &t, const vec5 &distCoeffs) |
| Projects a vector of inhomogenous 3d points to 2d using intrinsics and distortion parameters. | |
| void computeProjectionMatrix | ( | const vec3 & | C, |
| const vec3 & | p1, | ||
| const vec3 & | p2, | ||
| const vec3 & | p3, | ||
| const vec3 & | p4, | ||
| int | w, | ||
| int | h, | ||
| mat3 & | K, | ||
| mat3 & | R, | ||
| vec3 & | t ) |
Compute projection matrix for source-detector geometry p1, p2, p3 and p4 are the detector corner points in the order top-left, top-right, bottom-right and bottom-left as seen from the source.
I.e. the outer border of the image. The points are assumed to lie on a plane. C is the position of the source. w and h is the detector width and height in pixels. K, R and t contain the computed projection matrix components.
| bool computeProjectionMatrix | ( | const std::vector< vec3 > & | X, |
| const std::vector< vec2 > & | x, | ||
| mat34 & | P1, | ||
| mat34 & | P2, | ||
| bool & | P2IsAPossibleSolution ) |
Estimate projection matrix from point correspondences.
| X | 3D points |
| x | 2D points |
| P1 | projection matrix (a most probable solution) |
| P2 | projection matrix (another possible solution) |
| P2IsAPossibleSolution | flag specifying whether projection matrix P2 could be a correct solution |
| bool computeCameraPose | ( | const std::vector< vec3 > & | X, |
| const std::vector< vec2 > & | x, | ||
| const mat3 & | K, | ||
| const vec5 & | distCoeffs, | ||
| mat4 & | T, | ||
| double * | mre = nullptr, | ||
| std::vector< vec2 > * | reprojectedPoints = nullptr ) |
Estimate camera pose (i.e.
transformation from world to camera)
| X | 3D points |
| x | 2D points |
| K | intrinsic parameters |
| distCoeffs | distortion parameters |
| T | output camera pose |
| mre | optional output reprojection error |
| reprojectedPoints | optional output reprojected points |
| bool computeProjectionMatrix | ( | const std::vector< vec3 > & | X, |
| const std::vector< vec2 > & | x, | ||
| mat34 & | P ) |
Compute projection matrix from point correspondences.
| X | 3D points |
| x | 2D points |
| P | projection matrix |
| void normalizePoints | ( | const std::vector< vec2 > & | pts, |
| mat3 & | T ) |
Compute normalizing transformation for 2D points so that they are centered on the origin and the average distance from the origin is sqrt(2)
| pts | pts |
| T | normalizing transformation |
| void normalizePoints | ( | const std::vector< vec3 > & | pts, |
| mat4 & | T ) |
Compute normalizing transformation for 3D points so that they are centered on the origin and the average distance from the origin is sqrt(2)
| pts | pts |
| T | normalizing transformation |
| double computeReprojectionError | ( | const mat34 & | P, |
| const std::vector< vec3 > & | X, | ||
| const std::vector< vec2 > & | x ) |
Compute reprojection error.
| P | projection matrix |
| X | 3D points |
| x | 2D points |
| double computeReprojectionError | ( | const mat3 & | K, |
| const std::vector< mat3 > & | R, | ||
| const std::vector< vec3 > & | t, | ||
| const std::vector< vec3 > & | X, | ||
| const std::vector< std::vector< vec2 > > & | x, | ||
| const Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > & | vis ) |
Compute reprojection error over a sequence.
| K | intrinsic parameters |
| R | rotation matrices |
| t | translations |
| X | 3D points |
| x | 2D points |
| vis | visibility matrix |
| double triangulatePoint | ( | const std::vector< vec2 > & | x, |
| const std::vector< mat34 > & | P, | ||
| vec3 & | X, | ||
| bool | nonLinearRefinement = true ) |
Triangulate point given image measurements and projection matrices.
| x | image points |
| P | projection matrices |
| X | triangulated point |
| nonLinearRefinement | if true, triangulated point is refined using non-linear optimization after linear estimation |
| void convertComputerVisionToOpenGlProjectionMatrix | ( | const mat3 & | K, |
| const mat3 & | R, | ||
| const vec3 & | t, | ||
| int | width, | ||
| int | height, | ||
| double | near, | ||
| double | far, | ||
| mat4 & | PM, | ||
| mat4 & | MV, | ||
| bool | flipImageYAxis = false ) |
Convert a projection matrix to OpenGL representation from OpenCV convention In OpenCV convention the y-axis is flipped compared to OpenGL, and pixel coordinates are used.
| void convertOpenGlToComputerVisionProjectionMatrix | ( | const mat4 & | PM, |
| int | width, | ||
| int | height, | ||
| mat34 & | P ) |
Convert an OpenGL projection matrix to computer vision representation.
| void decomposeProjectionMatrix | ( | const mat34 & | P, |
| mat3 & | K, | ||
| mat3 & | R, | ||
| vec3 & | t, | ||
| bool | checkOpenCVConvention = true ) |
Decompose projection matrix into K, R and t.
| P | Matrix to be decomposed so that P = K * [R | t] |
| K | K matrix of P |
| R | R matrix of P |
| t | t vector from P |
| checkOpenCVConvention | If set to true the function will check if the determinant of R is positive. This should be the case e.g. when P is given in openCV coordinate convention. |
| vec3 reproject | ( | const mat4 & | projMat, |
| const vec2 & | imgPoint2D, | ||
| double | physicalWidth, | ||
| vec3 & | sourceOut3D, | ||
| vec3 & | imgOut3D, | ||
| vec3 & | zDirOut, | ||
| double & | fac ) |
Reprojects a point on the image plane using an OpenGL projection matrix.
| projMat | projection matrix in OpenGL notation |
| imgPoint2D | point on the image plane in normalized 0..1 coordinates, i.e 0 and 1 denoting the image borders. |
| physicalWidth | physical width of the image in mm |
| sourceOut3D | 3D position of the source/focal point |
| imgOut3D | 3D position of the point on the image plane |
| zDirOut | 3D ray direction of the principle point |
| fac | scaling factor such that factorOut * returnvalue points to the same plane as zDirOut |
| vec3 reproject | ( | const mat4 & | projMat, |
| const vec2 & | imgPoint2D, | ||
| double | physicalWidth, | ||
| vec3 & | sourceOut3D, | ||
| vec3 & | imgOut3D ) |
Reprojects a point on the image plane using an OpenGL projection matrix.
| projMat | projection matrix in OpenGL notation |
| imgPoint2D | point on the image plane in normalized 0..1 coordinates |
| physicalWidth | physical width of the image in mm |
| sourceOut3D | 3D position of the source/focal point |
| imgOut3D | 3D position of the point on the image plane |
| void unproject | ( | const mat3 & | invK, |
| double | dist, | ||
| const vec2 & | pt2d, | ||
| vec3 & | pt3d ) |
Unprojects a point on the image plane, where dist corresponds to the distance of pt3d from the xy plane and invK is the inverse calibration matrix of the camera.
| invK | inverse camera calibration matrix |
| dist | distance of the unprojected point 3D point to the xy-plane |
| pt2d | point on the image plane in pixel coordinates |
| pt3d | point in the world space that gets mapped into the image plane |
|
inline |
Projects a 3d point to 2d using a 3x4 projection matrix.
| P | 3x4 projection matrix | |
| pt3d | Homogenous 3d point | |
| [out] | pt2d | Projected Homogenous 2d point |
| normalize | Normalize 2d point |
|
inline |
Projects an inhomogenous 3d point to 2d using a 3x4 projection matrix.
| P | 3x4 projection matrix | |
| pt3d | Inhomogenous 3d point | |
| [out] | pt2d | Projected Homogenous 2d point |
| normalize | Normalize 2d point |
| std::vector< vec2 > projectPoints | ( | const std::vector< vec3 > & | pts3d, |
| const mat3 & | K, | ||
| const mat3 & | R, | ||
| const vec3 & | t, | ||
| const vec5 & | distCoeffs ) |
Projects a vector of inhomogenous 3d points to 2d using intrinsics and distortion parameters.
| pts3d | A vector of inhomogenous 3d points. |
| K | intrinsic parameters |
| R | rotation matrix of P |
| t | translation vector from P |
| distCoeffs | distortion parameters of the camera distortion model (k1 k2 p1 p2 k3) |