public class MultiViewOps
extends java.lang.Object
Contains commonly used operations used in 2-view and 3-view perspective geometry.
LINES: lines on the image place are represented in homogeneous or generic form as a 3D vector. If a point in homogeneous coordinates is on a line and the dot product is computed the result will be zero.
| Constructor and Description |
|---|
MultiViewOps() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
absoluteQuadraticToH(org.ejml.data.DMatrix4x4 Q,
org.ejml.data.DMatrixRMaj H)
Decomposes the absolute quadratic to extract the rectifying homogrpahy H.
|
static double |
constraint(org.ejml.data.DMatrixRMaj F,
georegression.struct.point.Point2D_F64 p1,
georegression.struct.point.Point2D_F64 p2)
Applies the epipolar relationship constraint to an essential or fundamental matrix:
0 = p2T*F*p1 Input points are in normalized image coordinates for an essential matrix and pixels for fundamental. |
static org.ejml.data.DMatrixRMaj |
constraint(TrifocalTensor tensor,
georegression.struct.point.Point2D_F64 p1,
georegression.struct.point.Point2D_F64 p2,
georegression.struct.point.Point2D_F64 p3,
org.ejml.data.DMatrixRMaj ret)
Trifocal tensor with point-point-point correspondence:
[p2]x(sum p1i*Ti)[p3]x = 0 |
static georegression.struct.point.Vector3D_F64 |
constraint(TrifocalTensor tensor,
georegression.struct.point.Point2D_F64 p1,
georegression.struct.point.Point2D_F64 p2,
georegression.struct.point.Vector3D_F64 l3,
georegression.struct.point.Vector3D_F64 ret)
Trifocal tensor with point-point-line correspondence:
[p2]x(sum p1i*Ti)*l3 = 0 |
static georegression.struct.point.Vector3D_F64 |
constraint(TrifocalTensor tensor,
georegression.struct.point.Point2D_F64 p1,
georegression.struct.point.Vector3D_F64 l2,
georegression.struct.point.Point2D_F64 p3,
georegression.struct.point.Vector3D_F64 ret)
Trifocal tensor with point-line-point correspondence:
(l2T(sum p1i*Ti)[p3]x = 0 |
static double |
constraint(TrifocalTensor tensor,
georegression.struct.point.Point2D_F64 p1,
georegression.struct.point.Vector3D_F64 l2,
georegression.struct.point.Vector3D_F64 l3)
Trifocal tensor with point-line-line correspondence:
(l2T*(sum p1i*Ti)*l3 = 0 |
static georegression.struct.point.Vector3D_F64 |
constraint(TrifocalTensor tensor,
georegression.struct.point.Vector3D_F64 l1,
georegression.struct.point.Vector3D_F64 l2,
georegression.struct.point.Vector3D_F64 l3,
georegression.struct.point.Vector3D_F64 ret)
Trifocal tensor with line-line-line correspondence:
(l2T*[T1,T2,T3]*L2)*[l1]x = 0 |
static georegression.struct.point.Point2D_F64 |
constraintHomography(org.ejml.data.DMatrixRMaj H,
georegression.struct.point.Point2D_F64 p1,
georegression.struct.point.Point2D_F64 outputP2)
Applies the homography constraints to two points:
z*p2 = H*p1 where z is a scale factor and (p1,p2) are point observations. |
static org.ejml.data.DMatrixRMaj |
createEssential(org.ejml.data.DMatrixRMaj R,
georegression.struct.point.Vector3D_F64 T,
org.ejml.data.DMatrixRMaj E)
Computes an essential matrix from a rotation and translation.
|
static org.ejml.data.DMatrixRMaj |
createFundamental(org.ejml.data.DMatrixRMaj E,
CameraPinhole intrinsic)
Computes a Fundamental matrix given an Essential matrix and the camera's intrinsic
parameters.
|
static org.ejml.data.DMatrixRMaj |
createFundamental(org.ejml.data.DMatrixRMaj E,
org.ejml.data.DMatrixRMaj K)
Computes a Fundamental matrix given an Essential matrix and the camera calibration matrix.
|
static org.ejml.data.DMatrixRMaj |
createFundamental(org.ejml.data.DMatrixRMaj E,
org.ejml.data.DMatrixRMaj K1,
org.ejml.data.DMatrixRMaj K2)
Computes a Fundamental matrix given an Essential matrix and the camera calibration matrix.
|
static org.ejml.data.DMatrixRMaj |
createFundamental(org.ejml.data.DMatrixRMaj R,
georegression.struct.point.Vector3D_F64 T,
org.ejml.data.DMatrixRMaj K1,
org.ejml.data.DMatrixRMaj K2,
org.ejml.data.DMatrixRMaj F)
Computes an fudamental matrix from a rotation, translation, and calibration matrix.
|
static org.ejml.data.DMatrixRMaj |
createHomography(org.ejml.data.DMatrixRMaj R,
georegression.struct.point.Vector3D_F64 T,
double d,
georegression.struct.point.Vector3D_F64 N)
Computes a homography matrix from a rotation, translation, plane normal and plane distance:
x[2] = H*x[1] where x[1] is the point on the first camera and x[2] the location in the second camera. H = R+(1/d)*T*NT Where [R,T] is the transform from camera 1 to camera 2. |
static org.ejml.data.DMatrixRMaj |
createHomography(org.ejml.data.DMatrixRMaj R,
georegression.struct.point.Vector3D_F64 T,
double d,
georegression.struct.point.Vector3D_F64 N,
org.ejml.data.DMatrixRMaj K)
Computes a homography matrix from a rotation, translation, plane normal, plane distance, and
calibration matrix:
x[2] = H*x[1] where x[1] is the point on the first camera and x[2] the location in the second camera. H = K*(R+(1/d)*T*NT)*K-1 Where [R,T] is the transform from camera 1 to camera, and K is the calibration matrix for both cameras. |
static org.ejml.data.DMatrixRMaj |
createProjectiveToMetric(org.ejml.data.DMatrixRMaj K,
double v1,
double v2,
double v3,
double lambda,
org.ejml.data.DMatrixRMaj H)
Given the calibration matrix for the first view, plane at infinity, and lambda (scaling factor) compute
the rectifying homography for changing a projective camera matrix into a metric one.
|
static TrifocalTensor |
createTrifocal(org.ejml.data.DMatrixRMaj P1,
org.ejml.data.DMatrixRMaj P2,
org.ejml.data.DMatrixRMaj P3,
TrifocalTensor ret)
Creates a trifocal tensor from three camera matrices.
|
static TrifocalTensor |
createTrifocal(org.ejml.data.DMatrixRMaj P2,
org.ejml.data.DMatrixRMaj P3,
TrifocalTensor ret)
Creates a trifocal tensor from two camera matrices.
|
static TrifocalTensor |
createTrifocal(georegression.struct.se.Se3_F64 P2,
georegression.struct.se.Se3_F64 P3,
TrifocalTensor ret)
Creates a trifocal tensor from two rigid body motions.
|
static boolean |
decomposeAbsDualQuadratic(org.ejml.data.DMatrix4x4 Q,
org.ejml.data.DMatrix3x3 w,
org.ejml.data.DMatrix3 p)
Decomposes the absolute dual quadratic into the following submatrices: Q=[w -w*p;-p'*w p'*w*p]
|
static void |
decomposeDiac(org.ejml.data.DMatrixRMaj w,
CameraPinhole intrinsic)
Extracts the camera calibration matrix on the dual image of the absolute conic (DIAC).
|
static void |
decomposeDiac(double w11,
double w12,
double w13,
double w22,
double w23,
double w33,
CameraPinhole intrinsic)
Extracts the camera calibration matrix on the dual image of the absolute conic (DIAC).
|
static java.util.List<georegression.struct.se.Se3_F64> |
decomposeEssential(org.ejml.data.DMatrixRMaj E21)
Decomposes an essential matrix into the rigid body motion which it was constructed from.
|
static java.util.List<org.ddogleg.struct.Tuple2<georegression.struct.se.Se3_F64,georegression.struct.point.Vector3D_F64>> |
decomposeHomography(org.ejml.data.DMatrixRMaj H)
Decomposes a homography matrix that's in Euclidean space (computed from features in normalized image coordinates).
|
static void |
decomposeMetricCamera(org.ejml.data.DMatrixRMaj cameraMatrix,
org.ejml.data.DMatrixRMaj K,
georegression.struct.se.Se3_F64 worldToView)
Decomposes a metric camera matrix P=K*[R|T], where A is an upper triangular camera calibration
matrix, R is a rotation matrix, and T is a translation vector.
|
static boolean |
enforceAbsoluteQuadraticConstraints(org.ejml.data.DMatrix4x4 Q,
boolean zeroCenter,
boolean zeroSkew)
If the solution to the absolute quadratic was computed using a linear methods it will not exactly have
the required structure.
|
static void |
errorsHomographySymm(java.util.List<AssociatedPair> observations,
org.ejml.data.DMatrixRMaj H,
org.ejml.data.DMatrixRMaj H_inv,
org.ddogleg.struct.GrowQueue_F64 storage)
Computes symmetric Euclidean error for each observation and puts it into the storage.
|
static void |
extractCameraMatrices(TrifocalTensor tensor,
org.ejml.data.DMatrixRMaj P2,
org.ejml.data.DMatrixRMaj P3)
Extract the camera matrices up to a common projective transform.
|
static void |
extractEpipoles(org.ejml.data.DMatrixRMaj F,
georegression.struct.point.Point3D_F64 e1,
georegression.struct.point.Point3D_F64 e2)
Extracts the epipoles from an essential or fundamental matrix.
|
static void |
extractEpipoles(TrifocalTensor tensor,
georegression.struct.point.Point3D_F64 e2,
georegression.struct.point.Point3D_F64 e3)
Computes the epipoles of the first camera in the second and third images.
|
static void |
extractFundamental(TrifocalTensor tensor,
org.ejml.data.DMatrixRMaj F21,
org.ejml.data.DMatrixRMaj F31)
Extract the fundamental matrices between views 1 + 2 and views 1 + 3.
|
static boolean |
fundamentalCompatible3(org.ejml.data.DMatrixRMaj F21,
org.ejml.data.DMatrixRMaj F31,
org.ejml.data.DMatrixRMaj F32,
double tol)
Checks to see if the three fundamental matrices are consistent based on their epipoles.
|
static org.ejml.data.DMatrixRMaj |
fundamentalToEssential(org.ejml.data.DMatrixRMaj F,
org.ejml.data.DMatrixRMaj K,
org.ejml.data.DMatrixRMaj outputE)
Given the calibration matrix, convert the fundamental matrix into an essential matrix.
|
static org.ejml.data.DMatrixRMaj |
fundamentalToProjective(org.ejml.data.DMatrixRMaj F)
Given a fundamental matrix a pair of camera matrices P0 and P1 can be extracted.
|
static void |
fundamentalToProjective(org.ejml.data.DMatrixRMaj F21,
org.ejml.data.DMatrixRMaj F31,
org.ejml.data.DMatrixRMaj F32,
org.ejml.data.DMatrixRMaj P2,
org.ejml.data.DMatrixRMaj P3)
Given three fundamental matrices that describing the relationship between three views, compute a consistent
set of projective camera matrices.
|
static org.ejml.data.DMatrixRMaj |
fundamentalToProjective(org.ejml.data.DMatrixRMaj F,
georegression.struct.point.Point3D_F64 e2,
georegression.struct.point.Vector3D_F64 v,
double lambda)
Given a fundamental matrix a pair of camera matrices P and P1' are extracted.
|
static org.ejml.data.DMatrixRMaj |
homographyStereo2Lines(org.ejml.data.DMatrixRMaj F,
PairLineNorm line0,
PairLineNorm line1)
Computes the homography induced from a planar surface when viewed from two views using correspondences
of two lines.
|
static org.ejml.data.DMatrixRMaj |
homographyStereo3Pts(org.ejml.data.DMatrixRMaj F,
AssociatedPair p1,
AssociatedPair p2,
AssociatedPair p3)
Computes the homography induced from a planar surface when viewed from two views using correspondences
of three points.
|
static org.ejml.data.DMatrixRMaj |
homographyStereoLinePt(org.ejml.data.DMatrixRMaj F,
PairLineNorm line,
AssociatedPair point)
Computes the homography induced from a planar surface when viewed from two views using correspondences
of a line and a point.
|
static org.ejml.data.DMatrixRMaj |
inducedHomography12(TrifocalTensor tensor,
georegression.struct.point.Vector3D_F64 line3,
org.ejml.data.DMatrixRMaj output)
Computes the homography induced from view 1 to 2 by a line in view 3.
|
static org.ejml.data.DMatrixRMaj |
inducedHomography13(TrifocalTensor tensor,
georegression.struct.point.Vector3D_F64 line2,
org.ejml.data.DMatrixRMaj output)
Computes the homography induced from view 1 to 3 by a line in view 2.
|
static void |
intrinsicFromAbsoluteQuadratic(org.ejml.data.DMatrixRMaj Q,
org.ejml.data.DMatrixRMaj P,
CameraPinhole intrinsic)
Extracts the intrinsic camera matrix from a view given its camera matrix and the dual absolute quadratic.
|
static org.ejml.data.DMatrixRMaj |
projectiveToFundamental(org.ejml.data.DMatrixRMaj P1,
org.ejml.data.DMatrixRMaj P2,
org.ejml.data.DMatrixRMaj F21)
Given two general camera matrices compute fundamental matrix.
|
static void |
projectiveToIdentityH(org.ejml.data.DMatrixRMaj P,
org.ejml.data.DMatrixRMaj H)
Finds the transform such that P*H = [I|0] where P is a 3x4 projective camera matrix and H is a 4x4 matrix
|
static void |
projectiveToMetric(org.ejml.data.DMatrixRMaj cameraMatrix,
org.ejml.data.DMatrixRMaj H,
georegression.struct.se.Se3_F64 worldToView,
org.ejml.data.DMatrixRMaj K)
Elevates a projective camera matrix into a metric one using the rectifying homography.
|
static void |
projectiveToMetricKnownK(org.ejml.data.DMatrixRMaj cameraMatrix,
org.ejml.data.DMatrixRMaj H,
org.ejml.data.DMatrixRMaj K,
georegression.struct.se.Se3_F64 worldToView)
Convert the projective camera matrix into a metric transform given the rectifying homography and a
known calibration matrix.
|
static void |
rectifyHToAbsoluteQuadratic(org.ejml.data.DMatrixRMaj H,
org.ejml.data.DMatrixRMaj Q)
Rectifying homography to dual absolute quadratic.
|
static org.ddogleg.struct.Tuple2<java.util.List<georegression.struct.point.Point2D_F64>,java.util.List<georegression.struct.point.Point2D_F64>> |
split2(java.util.List<AssociatedPair> input)
Splits the associated pairs into two lists
|
static org.ddogleg.struct.Tuple3<java.util.List<georegression.struct.point.Point2D_F64>,java.util.List<georegression.struct.point.Point2D_F64>,java.util.List<georegression.struct.point.Point2D_F64>> |
split3(java.util.List<AssociatedTriple> input)
Splits the associated triple into three lists
|
static georegression.struct.point.Point3D_F64 |
transfer_1_to_2(TrifocalTensor T,
georegression.struct.point.Point2D_F64 x1,
georegression.struct.point.Point2D_F64 x2,
georegression.struct.point.Point3D_F64 x3)
Transfers a point from the first view to the second view using the observed location in the third view
|
static georegression.struct.point.Point3D_F64 |
transfer_1_to_2(TrifocalTensor T,
georegression.struct.point.Point2D_F64 x1,
georegression.struct.point.Vector3D_F64 l3,
georegression.struct.point.Point3D_F64 x2)
Transfers a point from the first view to the second view using a plane induced by
a line in the third view.
|
static georegression.struct.point.Point3D_F64 |
transfer_1_to_3(TrifocalTensor T,
georegression.struct.point.Point2D_F64 x1,
georegression.struct.point.Point2D_F64 x3,
georegression.struct.point.Point3D_F64 x2)
Transfers a point from the first view to the second view using the observed location in the third view
|
static georegression.struct.point.Point3D_F64 |
transfer_1_to_3(TrifocalTensor T,
georegression.struct.point.Point2D_F64 x1,
georegression.struct.point.Vector3D_F64 l2,
georegression.struct.point.Point3D_F64 x3)
Transfers a point from the first view to the third view using a plane induced by
a line in the second view.
|
static void |
triangulatePoints(SceneStructureMetric structure,
SceneObservations observations)
Convience function for initializing bundle adjustment parameters.
|
public static TrifocalTensor createTrifocal(org.ejml.data.DMatrixRMaj P2, org.ejml.data.DMatrixRMaj P3, @Nullable TrifocalTensor ret)
Creates a trifocal tensor from two camera matrices. Tijk = a[j,i]*b[k,3] - a[j,3]*b[k,i], where a=P2 and b=P3.
IMPORTANT: It is assumed that the first camera has the following camera matrix P1 = [I|0], where I is an identify matrix.
P2 - Camera matrix for view 2. 3x4 matrixP3 - Camera matrix for view 3. 3x4 matrixret - Storage for trifocal tensor. If null a new instance will be created.public static TrifocalTensor createTrifocal(org.ejml.data.DMatrixRMaj P1, org.ejml.data.DMatrixRMaj P2, org.ejml.data.DMatrixRMaj P3, @Nullable TrifocalTensor ret)
Creates a trifocal tensor from three camera matrices. The
Page 415 in R. Hartley, and A. Zisserman, "Multiple View Geometry in Computer Vision", 2nd Ed, Cambridge 2003
P2 - Camera matrix for view 1. 3x4 matrixP2 - Camera matrix for view 2. 3x4 matrixP3 - Camera matrix for view 3. 3x4 matrixret - Storage for trifocal tensor. If null a new instance will be created.public static TrifocalTensor createTrifocal(georegression.struct.se.Se3_F64 P2, georegression.struct.se.Se3_F64 P3, @Nullable TrifocalTensor ret)
Creates a trifocal tensor from two rigid body motions. This is for the calibrated camera case.
NOTE: View 1 is the world coordinate system, i.e. [I|0]
P2 - Transform from view 1 to view 2.P3 - Transform from view 1 to view 3.ret - Storage for trifocal tensor. If null a new instance will be created.public static georegression.struct.point.Vector3D_F64 constraint(TrifocalTensor tensor, georegression.struct.point.Vector3D_F64 l1, georegression.struct.point.Vector3D_F64 l2, georegression.struct.point.Vector3D_F64 l3, @Nullable georegression.struct.point.Vector3D_F64 ret)
Trifocal tensor with line-line-line correspondence:
(l2T*[T1,T2,T3]*L2)*[l1]x = 0
tensor - Trifocal tensorl1 - A line in the first view.l2 - A line in the second view.l3 - A line in the third view.ret - Storage for output. If null a new instance will be declared.public static double constraint(TrifocalTensor tensor, georegression.struct.point.Point2D_F64 p1, georegression.struct.point.Vector3D_F64 l2, georegression.struct.point.Vector3D_F64 l3)
Trifocal tensor with point-line-line correspondence:
(l2T*(sum p1i*Ti)*l3 = 0
tensor - Trifocal tensorp1 - A point in the first view.l2 - A line in the second view.l3 - A line in the third view.public static georegression.struct.point.Vector3D_F64 constraint(TrifocalTensor tensor, georegression.struct.point.Point2D_F64 p1, georegression.struct.point.Vector3D_F64 l2, georegression.struct.point.Point2D_F64 p3, georegression.struct.point.Vector3D_F64 ret)
Trifocal tensor with point-line-point correspondence:
(l2T(sum p1i*Ti)[p3]x = 0
tensor - Trifocal tensorp1 - A point in the first view.l2 - A line in the second view.p3 - A point in the third view.public static georegression.struct.point.Vector3D_F64 constraint(TrifocalTensor tensor, georegression.struct.point.Point2D_F64 p1, georegression.struct.point.Point2D_F64 p2, georegression.struct.point.Vector3D_F64 l3, georegression.struct.point.Vector3D_F64 ret)
Trifocal tensor with point-point-line correspondence:
[p2]x(sum p1i*Ti)*l3 = 0
tensor - Trifocal tensorp1 - A point in the first view.p2 - A point in the second view.l3 - A line in the third view.public static org.ejml.data.DMatrixRMaj constraint(TrifocalTensor tensor, georegression.struct.point.Point2D_F64 p1, georegression.struct.point.Point2D_F64 p2, georegression.struct.point.Point2D_F64 p3, org.ejml.data.DMatrixRMaj ret)
Trifocal tensor with point-point-point correspondence:
[p2]x(sum p1i*Ti)[p3]x = 0
tensor - Trifocal tensorp1 - A point in the first view.p2 - A point in the second view.p3 - A point in the third view.ret - Optional storage for output. 3x3 matrix. Modified.public static double constraint(org.ejml.data.DMatrixRMaj F,
georegression.struct.point.Point2D_F64 p1,
georegression.struct.point.Point2D_F64 p2)
Applies the epipolar relationship constraint to an essential or fundamental matrix:
0 = p2T*F*p1
Input points are in normalized image coordinates for an essential matrix and pixels for
fundamental.
F - 3x3 essential or fundamental matrix.p1 - Point in view 1.p2 - Point in view 2.public static georegression.struct.point.Point2D_F64 constraintHomography(org.ejml.data.DMatrixRMaj H,
georegression.struct.point.Point2D_F64 p1,
georegression.struct.point.Point2D_F64 outputP2)
Applies the homography constraints to two points:
z*p2 = H*p1
where z is a scale factor and (p1,p2) are point observations. Note that since 2D points are inputted
translation and normalization to homogeneous coordinates with z=1 is automatically handled.
H - Input: 3x3 Homography matrix.p1 - Input: Point in view 1.outputP2 - Output: storage for point in view 2.public static org.ejml.data.DMatrixRMaj inducedHomography13(TrifocalTensor tensor, georegression.struct.point.Vector3D_F64 line2, org.ejml.data.DMatrixRMaj output)
tensor - Input: Trifocal tensorline2 - Input: Line in view 2. General notation.output - Output: Optional storage for homography. 3x3 matrixpublic static org.ejml.data.DMatrixRMaj inducedHomography12(TrifocalTensor tensor, georegression.struct.point.Vector3D_F64 line3, org.ejml.data.DMatrixRMaj output)
tensor - Input: Trifocal tensorline3 - Input: Line in view 3. General notation.output - Output: Optional storage for homography. 3x3 matrixpublic static org.ejml.data.DMatrixRMaj homographyStereo3Pts(org.ejml.data.DMatrixRMaj F,
AssociatedPair p1,
AssociatedPair p2,
AssociatedPair p3)
F - Fundamental matrixp1 - Associated point observationp2 - Associated point observationp3 - Associated point observationHomographyInducedStereo3Ptspublic static org.ejml.data.DMatrixRMaj homographyStereoLinePt(org.ejml.data.DMatrixRMaj F,
PairLineNorm line,
AssociatedPair point)
F - Fundamental matrixline - Line on the planepoint - Point on the planeHomographyInducedStereoLinePtpublic static org.ejml.data.DMatrixRMaj homographyStereo2Lines(org.ejml.data.DMatrixRMaj F,
PairLineNorm line0,
PairLineNorm line1)
F - Fundamental matrixline0 - Line on the planeline1 - Line on the planeHomographyInducedStereo2Linepublic static void extractEpipoles(TrifocalTensor tensor, georegression.struct.point.Point3D_F64 e2, georegression.struct.point.Point3D_F64 e3)
Computes the epipoles of the first camera in the second and third images. Epipoles are found in homogeneous coordinates and have a norm of 1.
Properties:
tensor - Trifocal tensor. Not Modifiede2 - Output: Epipole in image 2. Homogeneous coordinates. Modifiede3 - Output: Epipole in image 3. Homogeneous coordinates. ModifiedTrifocalExtractGeometriespublic static void extractFundamental(TrifocalTensor tensor, org.ejml.data.DMatrixRMaj F21, org.ejml.data.DMatrixRMaj F31)
Extract the fundamental matrices between views 1 + 2 and views 1 + 3. The returned Fundamental matrices will have the following properties: xiT*Fi*x1 = 0, where i is view 2 or 3.
NOTE: The first camera is assumed to have the camera matrix of P1 = [I|0]. Thus observations in pixels for the first camera will not meet the epipolar constraint when applied to the returned fundamental matrices.
tensor - Trifocal tensor. Not modified.F21 - Output: Fundamental matrix for views 1 and 2. Modified.F31 - Output: Fundamental matrix for views 1 and 3. Modified.TrifocalExtractGeometriespublic static void extractCameraMatrices(TrifocalTensor tensor, org.ejml.data.DMatrixRMaj P2, org.ejml.data.DMatrixRMaj P3)
Extract the camera matrices up to a common projective transform.
NOTE: The camera matrix for the first view is assumed to be P1 = [I|0].
tensor - Trifocal tensor. Not modified.P2 - Output: 3x4 camera matrix for views 1 to 2. Modified.P3 - Output: 3x4 camera matrix for views 1 to 3. Modified.TrifocalExtractGeometriespublic static org.ejml.data.DMatrixRMaj createEssential(org.ejml.data.DMatrixRMaj R,
georegression.struct.point.Vector3D_F64 T,
@Nullable
org.ejml.data.DMatrixRMaj E)
Computes an essential matrix from a rotation and translation. This motion
is the motion from the first camera frame into the second camera frame. The essential
matrix 'E' is defined as:
E = hat(T)*R
where hat(T) is the skew symmetric cross product matrix for vector T.
R - Rotation matrix.T - Translation vector.E - (Output) Storage for essential matrix. 3x3 matrixpublic static org.ejml.data.DMatrixRMaj createFundamental(org.ejml.data.DMatrixRMaj E,
org.ejml.data.DMatrixRMaj K)
E - Essential matrixK - Intrinsic camera calibration matrixpublic static org.ejml.data.DMatrixRMaj createFundamental(org.ejml.data.DMatrixRMaj E,
CameraPinhole intrinsic)
E - Essential matrixintrinsic - Intrinsic camera calibrationcreateFundamental(DMatrixRMaj, DMatrixRMaj)public static org.ejml.data.DMatrixRMaj createFundamental(org.ejml.data.DMatrixRMaj E,
org.ejml.data.DMatrixRMaj K1,
org.ejml.data.DMatrixRMaj K2)
E - Essential matrixK1 - Intrinsic camera calibration matrix for camera 1K2 - Intrinsic camera calibration matrix for camera 2public static org.ejml.data.DMatrixRMaj createFundamental(org.ejml.data.DMatrixRMaj R,
georegression.struct.point.Vector3D_F64 T,
org.ejml.data.DMatrixRMaj K1,
org.ejml.data.DMatrixRMaj K2,
@Nullable
org.ejml.data.DMatrixRMaj F)
Computes an fudamental matrix from a rotation, translation, and calibration matrix. Motion is from the first camera frame into the second camera frame.
R - Rotation matrix. first to secondT - Translation vector. first to secondK1 - Intrinsic camera calibration matrix for camera 1K2 - Intrinsic camera calibration matrix for camera 2F - (Output) Storage for essential matrix. 3x3 matrixpublic static org.ejml.data.DMatrixRMaj createHomography(org.ejml.data.DMatrixRMaj R,
georegression.struct.point.Vector3D_F64 T,
double d,
georegression.struct.point.Vector3D_F64 N)
Computes a homography matrix from a rotation, translation, plane normal and plane distance:
x[2] = H*x[1]
where x[1] is the point on the first camera and x[2] the location in the second camera.
H = R+(1/d)*T*NT
Where [R,T] is the transform from camera 1 to camera 2.
R - Rotation matrix from camera 1 to camera 2.T - Translation vector from camera 1 to camera 2.d - Distance > 0 of closest point on plane to the origin of camera 1.N - Normal of plane with respect to the first camera.public static org.ejml.data.DMatrixRMaj createHomography(org.ejml.data.DMatrixRMaj R,
georegression.struct.point.Vector3D_F64 T,
double d,
georegression.struct.point.Vector3D_F64 N,
org.ejml.data.DMatrixRMaj K)
Computes a homography matrix from a rotation, translation, plane normal, plane distance, and
calibration matrix:
x[2] = H*x[1]
where x[1] is the point on the first camera and x[2] the location in the second camera.
H = K*(R+(1/d)*T*NT)*K-1
Where [R,T] is the transform from camera 1 to camera, and K is the calibration matrix for both cameras.
R - Rotation matrix from camera 1 to camera 2.T - Translation vector from camera 1 to camera 2.d - Distance > 0 of closest point on plane to the origin of camera 1.N - Normal of plane with respect to the first camera.K - Intrinsic calibration matrixpublic static void extractEpipoles(org.ejml.data.DMatrixRMaj F,
georegression.struct.point.Point3D_F64 e1,
georegression.struct.point.Point3D_F64 e2)
Extracts the epipoles from an essential or fundamental matrix. The epipoles are extracted from the left and right null space of the provided matrix. Note that the found epipoles are in homogeneous coordinates. If the epipole is at infinity then z=0
Left: e2T*F = 0
Right: F*e1 = 0
F - Input: Fundamental or Essential 3x3 matrix. Not modified.e1 - Output: Right epipole in homogeneous coordinates. Can be null. Modified.e2 - Output: Left epipole in homogeneous coordinates. Can be null. Modified.public static org.ejml.data.DMatrixRMaj fundamentalToProjective(org.ejml.data.DMatrixRMaj F,
georegression.struct.point.Point3D_F64 e2,
georegression.struct.point.Vector3D_F64 v,
double lambda)
Given a fundamental matrix a pair of camera matrices P and P1' are extracted. The camera matrices
are 3 by 4 and used to project a 3D homogenous point onto the image plane. These camera matrices will only
be known up to a projective transform, thus there are multiple solutions, The canonical camera
matrix is defined as:
P=[I|0] and P'= [M|-M*t] = [[e']*F + e'*v^t | lambda*e']where e' is the epipole FTe' = 0, [e'] is the cross product matrix for the enclosed vector, v is an arbitrary 3-vector and lambda is a non-zero scalar.
NOTE: Additional information is needed to upgrade this projective transform into a metric transform.
Page 256 in R. Hartley, and A. Zisserman, "Multiple View Geometry in Computer Vision", 2nd Ed, Cambridge 2003
F - (Input) A fundamental matrixe2 - (Input) Left epipole of fundamental matrix, FT*e2 = 0.v - (Input) Arbitrary 3-vector. Just pick some value, say (0,0,0).lambda - (Input) A non zero scalar. Try one.extractEpipoles(boofcv.struct.geo.TrifocalTensor, georegression.struct.point.Point3D_F64, georegression.struct.point.Point3D_F64),
FundamentalToProjectivepublic static org.ejml.data.DMatrixRMaj projectiveToFundamental(org.ejml.data.DMatrixRMaj P1,
org.ejml.data.DMatrixRMaj P2,
@Nullable
org.ejml.data.DMatrixRMaj F21)
Given two general camera matrices compute fundamental matrix.
F= [e']_x P2*P1+, where P1+ is the pseudo inverse of P1, and e' = P2*C, with P*C=0P1 - (Input) camera matrix for view 1P2 - (Input) camera matrix for view 2F21 - (Output) Fundamental matrix from view 1 to 2public static org.ejml.data.DMatrixRMaj fundamentalToProjective(org.ejml.data.DMatrixRMaj F)
Given a fundamental matrix a pair of camera matrices P0 and P1 can be extracted. Same
fundamentalToProjective(DMatrixRMaj, Point3D_F64, Vector3D_F64, double) but with the suggested values
for all variables filled in for you.
F - (Input) Fundamental MatrixFundamentalToProjectivepublic static org.ejml.data.DMatrixRMaj fundamentalToEssential(org.ejml.data.DMatrixRMaj F,
org.ejml.data.DMatrixRMaj K,
@Nullable
org.ejml.data.DMatrixRMaj outputE)
F - (Input) Fundamental matrix. 3x3K - (Input) Calibration matrix (3x3)outputE - (Output) Found essential matrixpublic static void fundamentalToProjective(org.ejml.data.DMatrixRMaj F21,
org.ejml.data.DMatrixRMaj F31,
org.ejml.data.DMatrixRMaj F32,
org.ejml.data.DMatrixRMaj P2,
org.ejml.data.DMatrixRMaj P3)
FundamentalToProjective.threeView(org.ejml.data.DMatrixRMaj, org.ejml.data.DMatrixRMaj, org.ejml.data.DMatrixRMaj, org.ejml.data.DMatrixRMaj, org.ejml.data.DMatrixRMaj).
The first camera matrix, without loss of generality, is assumed to be P1 = [I|0].
F21 - (Input) Fundamental matrix between view 1 and 2F31 - (Input) Fundamental matrix between view 1 and 3F32 - (Input) Fundamental matrix between view 2 and 3P2 - (Output) Camera matrix for view 2P3 - (Output) Camera matrix for view 3fundamentalCompatible3(org.ejml.data.DMatrixRMaj, org.ejml.data.DMatrixRMaj, org.ejml.data.DMatrixRMaj, double),
FundamentalToProjective.threeView(org.ejml.data.DMatrixRMaj, org.ejml.data.DMatrixRMaj, org.ejml.data.DMatrixRMaj, org.ejml.data.DMatrixRMaj, org.ejml.data.DMatrixRMaj)public static void projectiveToIdentityH(org.ejml.data.DMatrixRMaj P,
org.ejml.data.DMatrixRMaj H)
P - (Input) camera matrix 3x4H - (Output) 4x4 matrixpublic static boolean fundamentalCompatible3(org.ejml.data.DMatrixRMaj F21,
org.ejml.data.DMatrixRMaj F31,
org.ejml.data.DMatrixRMaj F32,
double tol)
Checks to see if the three fundamental matrices are consistent based on their epipoles.
e23TF21e13 = 0
e31TF32e21 = 0
e32TF31e12 = 0
Section 15.4 in R. Hartley, and A. Zisserman, "Multiple View Geometry in Computer Vision", 2nd Ed, Cambridge 2003
F21 - (Input) Fundamental matrix between view 1 and 2F31 - (Input) Fundamental matrix between view 1 and 3F32 - (Input) Fundamental matrix between view 2 and 3public static void decomposeMetricCamera(org.ejml.data.DMatrixRMaj cameraMatrix,
org.ejml.data.DMatrixRMaj K,
georegression.struct.se.Se3_F64 worldToView)
Decomposes a metric camera matrix P=K*[R|T], where A is an upper triangular camera calibration matrix, R is a rotation matrix, and T is a translation vector.
cameraMatrix - Input: Camera matrix, 3 by 4K - Output: Camera calibration matrix, 3 by 3.worldToView - Output: The rotation and translation.public static java.util.List<georegression.struct.se.Se3_F64> decomposeEssential(org.ejml.data.DMatrixRMaj E21)
DecomposeEssential for the details. The correct solution can
be found using triangulation and the positive depth constraint, e.g. the objects must be in front of the camera
to be seen. Also note that the scale of the translation is lost, even with perfect data.E21 - An essential matrix.DecomposeEssentialpublic static java.util.List<org.ddogleg.struct.Tuple2<georegression.struct.se.Se3_F64,georegression.struct.point.Vector3D_F64>> decomposeHomography(org.ejml.data.DMatrixRMaj H)
H - Homography in Euclidean spaceDecomposeHomographypublic static void errorsHomographySymm(java.util.List<AssociatedPair> observations, org.ejml.data.DMatrixRMaj H, @Nullable org.ejml.data.DMatrixRMaj H_inv, org.ddogleg.struct.GrowQueue_F64 storage)
Computes symmetric Euclidean error for each observation and puts it into the storage. If the homography projects the point into the plane at infinity (z=0) then it is skipped
error[i] = (H*x1 - x2')**2 + (inv(H)*x2 - x1')**2observations - (Input) observationsH - (Input) HomographyH_inv - (Input) Inverse of homography. if null it will be computed internallystorage - (Output) storage for found errorspublic static georegression.struct.point.Point3D_F64 transfer_1_to_3(TrifocalTensor T, georegression.struct.point.Point2D_F64 x1, georegression.struct.point.Vector3D_F64 l2, @Nullable georegression.struct.point.Point3D_F64 x3)
x1 - (Input) point (pixel) in first viewl2 - (Input) line in second viewT - (Input) Trifocal tensorx3 - (Output) Induced point (pixel) in third view. Homogenous coordinates.public static georegression.struct.point.Point3D_F64 transfer_1_to_3(TrifocalTensor T, georegression.struct.point.Point2D_F64 x1, georegression.struct.point.Point2D_F64 x3, @Nullable georegression.struct.point.Point3D_F64 x2)
x1 - (Input) point (pixel) in first viewx2 - (Input) point (pixel) in second viewT - (Input) Trifocal tensorx3 - (Output) Induced point (pixel) in third view. Homogenous coordinates.public static georegression.struct.point.Point3D_F64 transfer_1_to_2(TrifocalTensor T, georegression.struct.point.Point2D_F64 x1, georegression.struct.point.Vector3D_F64 l3, @Nullable georegression.struct.point.Point3D_F64 x2)
x1 - (Input) point (pixel) in first viewl3 - (Input) line in third viewT - (Input) Trifocal tensorx2 - (Output) Induced point (pixel) in second view. Homogenous coordinates.public static georegression.struct.point.Point3D_F64 transfer_1_to_2(TrifocalTensor T, georegression.struct.point.Point2D_F64 x1, georegression.struct.point.Point2D_F64 x2, @Nullable georegression.struct.point.Point3D_F64 x3)
x1 - (Input) point (pixel) in first viewx3 - (Input) point (pixel) in third viewT - (Input) Trifocal tensorx2 - (Output) Induced point (pixel) in second view. Homogenous coordinates.public static void projectiveToMetric(org.ejml.data.DMatrixRMaj cameraMatrix,
org.ejml.data.DMatrixRMaj H,
georegression.struct.se.Se3_F64 worldToView,
org.ejml.data.DMatrixRMaj K)
P'=P*H K,R,t = decompose(P')where P is the camera matrix, H is the homography, (K,R,t) are the intrinsic calibration matrix, rotation, and translation
cameraMatrix - (Input) camera matrix. 3x4H - (Input) Rectifying homography. 4x4worldToView - (Output) Transform from world to camera viewK - (Output) Camera calibration matrixabsoluteQuadraticToH(org.ejml.data.DMatrix4x4, org.ejml.data.DMatrixRMaj),
decomposeMetricCamera(DMatrixRMaj, DMatrixRMaj, Se3_F64)public static void projectiveToMetricKnownK(org.ejml.data.DMatrixRMaj cameraMatrix,
org.ejml.data.DMatrixRMaj H,
org.ejml.data.DMatrixRMaj K,
georegression.struct.se.Se3_F64 worldToView)
P = K*[R|T]*H where H is the inverse of the rectifying homography.cameraMatrix - (Input) camera matrix. 3x4H - (Input) Rectifying homography. 4x4K - (Input) Known calibration matrixworldToView - (Output) transform from world to camera viewpublic static boolean enforceAbsoluteQuadraticConstraints(org.ejml.data.DMatrix4x4 Q,
boolean zeroCenter,
boolean zeroSkew)
Q - Approximate solution to absolute quadraticDecomposeAbsoluteDualQuadraticpublic static boolean absoluteQuadraticToH(org.ejml.data.DMatrix4x4 Q,
org.ejml.data.DMatrixRMaj H)
Q = H*I*HT
where I = diag(1 1 1 0)
Q - (Input) Absolute quadratic. Typically found in auto calibration. Not modified.H - (Output) 4x4 rectifying homography.DecomposeAbsoluteDualQuadraticpublic static void rectifyHToAbsoluteQuadratic(org.ejml.data.DMatrixRMaj H,
org.ejml.data.DMatrixRMaj Q)
Q = H*I*HT = H(:,1:3)*H(:,1:3)'
where I = diag(1 1 1 0)
H - (Input) 4x4 rectifying homography.Q - (Output) Absolute quadratic. Typically found in auto calibration. Not modified.public static void intrinsicFromAbsoluteQuadratic(org.ejml.data.DMatrixRMaj Q,
org.ejml.data.DMatrixRMaj P,
CameraPinhole intrinsic)
wi = Pi*Q*PiT, where wi = Ki*K'i
Q - (Input) Dual absolute qudraticP - (Input) Camera matrix for a viewintrinsic - (Output) found intrinsic parameterspublic static void decomposeDiac(double w11,
double w12,
double w13,
double w22,
double w23,
double w33,
CameraPinhole intrinsic)
intrinsic - (output) K extracted from wpublic static void decomposeDiac(org.ejml.data.DMatrixRMaj w,
CameraPinhole intrinsic)
w - (input) DIAC 3x3intrinsic - (output) K extracted from wpublic static org.ejml.data.DMatrixRMaj createProjectiveToMetric(org.ejml.data.DMatrixRMaj K,
double v1,
double v2,
double v3,
double lambda,
@Nullable
org.ejml.data.DMatrixRMaj H)
H = [K 0;v' &lambda]
K - 3x3 calibration matrix for view 1v1 - plane at infinityv2 - plane at infinityv3 - plane at infinitylambda - scaling factorH - (Optional) Storage for 4x4 matrixpublic static boolean decomposeAbsDualQuadratic(org.ejml.data.DMatrix4x4 Q,
org.ejml.data.DMatrix3x3 w,
org.ejml.data.DMatrix3 p)
Q - (Input) Absolute quadratic. Typically found in auto calibration. Not modified.w - (Output) 3x3 symmetric matrixp - (Output) 3x1 vectorDecomposeAbsoluteDualQuadraticpublic static org.ddogleg.struct.Tuple2<java.util.List<georegression.struct.point.Point2D_F64>,java.util.List<georegression.struct.point.Point2D_F64>> split2(java.util.List<AssociatedPair> input)
input - List of associated featurespublic static org.ddogleg.struct.Tuple3<java.util.List<georegression.struct.point.Point2D_F64>,java.util.List<georegression.struct.point.Point2D_F64>,java.util.List<georegression.struct.point.Point2D_F64>> split3(java.util.List<AssociatedTriple> input)
input - List of associated featurespublic static void triangulatePoints(SceneStructureMetric structure, SceneObservations observations)
structure - observations -