Class MultiViewOps
- java.lang.Object
-
- boofcv.alg.geo.MultiViewOps
-
public class MultiViewOps extends java.lang.ObjectContains 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 Summary
Constructors Constructor Description MultiViewOps()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanabsoluteQuadraticToH(org.ejml.data.DMatrix4x4 Q, org.ejml.data.DMatrixRMaj H)Decomposes the absolute quadratic to extract the rectifying homogrpahy H.static org.ejml.data.DMatrixRMajconstraint(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 = 0static georegression.struct.point.Vector3D_F64constraint(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 = 0static georegression.struct.point.Vector3D_F64constraint(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 = 0static doubleconstraint(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 = 0static georegression.struct.point.Vector3D_F64constraint(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 = 0static doubleconstraint(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 georegression.struct.point.Point2D_F64constraintHomography(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.DMatrixRMajcreateEssential(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.DMatrixRMajcreateFundamental(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.DMatrixRMajcreateFundamental(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.DMatrixRMajcreateFundamental(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.DMatrixRMajcreateFundamental(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.DMatrixRMajcreateHomography(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.DMatrixRMajcreateHomography(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.DMatrixRMajcreateProjectiveToMetric(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 TrifocalTensorcreateTrifocal(georegression.struct.se.Se3_F64 P2, georegression.struct.se.Se3_F64 P3, TrifocalTensor ret)Creates a trifocal tensor from two rigid body motions.static TrifocalTensorcreateTrifocal(org.ejml.data.DMatrixRMaj P2, org.ejml.data.DMatrixRMaj P3, TrifocalTensor ret)Creates a trifocal tensor from two camera matrices.static TrifocalTensorcreateTrifocal(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 booleandecomposeAbsDualQuadratic(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 voiddecomposeDiac(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 voiddecomposeDiac(org.ejml.data.DMatrixRMaj w, 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 voiddecomposeMetricCamera(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 booleanenforceAbsoluteQuadraticConstraints(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 voiderrorsHomographySymm(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 voidextractCameraMatrices(TrifocalTensor tensor, org.ejml.data.DMatrixRMaj P2, org.ejml.data.DMatrixRMaj P3)Extract the camera matrices up to a common projective transform.static voidextractEpipoles(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 voidextractEpipoles(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 voidextractFundamental(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 booleanfundamentalCompatible3(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.DMatrixRMajfundamentalToEssential(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.DMatrixRMajfundamentalToProjective(org.ejml.data.DMatrixRMaj F)Given a fundamental matrix a pair of camera matrices P0 and P1 can be extracted.static org.ejml.data.DMatrixRMajfundamentalToProjective(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 voidfundamentalToProjective(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.DMatrixRMajhomographyStereo2Lines(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.DMatrixRMajhomographyStereo3Pts(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.DMatrixRMajhomographyStereoLinePt(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.DMatrixRMajinducedHomography12(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.DMatrixRMajinducedHomography13(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 voidintrinsicFromAbsoluteQuadratic(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.DMatrixRMajprojectiveToFundamental(org.ejml.data.DMatrixRMaj P1, org.ejml.data.DMatrixRMaj P2, org.ejml.data.DMatrixRMaj F21)Given two general camera matrices compute fundamental matrix.static voidprojectiveToIdentityH(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 matrixstatic voidprojectiveToMetric(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 voidprojectiveToMetricKnownK(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 voidrectifyHToAbsoluteQuadratic(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 listsstatic 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 listsstatic georegression.struct.point.Point3D_F64transfer_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 viewstatic georegression.struct.point.Point3D_F64transfer_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_F64transfer_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 viewstatic georegression.struct.point.Point3D_F64transfer_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 voidtriangulatePoints(SceneStructureMetric structure, SceneObservations observations)Convience function for initializing bundle adjustment parameters.
-
-
-
Method Detail
-
createTrifocal
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.
- Parameters:
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.- Returns:
- The trifocal tensor
-
createTrifocal
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
- Parameters:
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.- Returns:
- The trifocal tensor
-
createTrifocal
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]
- Parameters:
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.- Returns:
- The trifocal tensor
-
constraint
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- Parameters:
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.- Returns:
- Result of applying the constraint. With perfect inputs will be zero.
-
constraint
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- Parameters:
tensor- Trifocal tensorp1- A point in the first view.l2- A line in the second view.l3- A line in the third view.- Returns:
- Result of applying the constraint. With perfect inputs will be zero.
-
constraint
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- Parameters:
tensor- Trifocal tensorp1- A point in the first view.l2- A line in the second view.p3- A point in the third view.- Returns:
- Result of applying the constraint. With perfect inputs will be zero.
-
constraint
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- Parameters:
tensor- Trifocal tensorp1- A point in the first view.p2- A point in the second view.l3- A line in the third view.- Returns:
- Result of applying the constraint. With perfect inputs will be zero.
-
constraint
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- Parameters:
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.- Returns:
- Result of applying the constraint. With perfect inputs will be zero.
-
constraint
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.- Parameters:
F- 3x3 essential or fundamental matrix.p1- Point in view 1.p2- Point in view 2.- Returns:
- Constraint value.
-
constraintHomography
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.- Parameters:
H- Input: 3x3 Homography matrix.p1- Input: Point in view 1.outputP2- Output: storage for point in view 2.- Returns:
- Predicted point in view 2
-
inducedHomography13
public 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. The provided line in view 2 must contain the view 2 observation. p3 = H13*p1- Parameters:
tensor- Input: Trifocal tensorline2- Input: Line in view 2.General notation.output- Output: Optional storage for homography. 3x3 matrix- Returns:
- Homography from view 1 to 3
-
inducedHomography12
public 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. The provided line in view 3 must contain the view 3 observation. p2 = H12*p1- Parameters:
tensor- Input: Trifocal tensorline3- Input: Line in view 3.General notation.output- Output: Optional storage for homography. 3x3 matrix- Returns:
- Homography from view 1 to 2
-
homographyStereo3Pts
public 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. Observations must be on the planar surface.- Parameters:
F- Fundamental matrixp1- Associated point observationp2- Associated point observationp3- Associated point observation- Returns:
- The homography from view 1 to view 2 or null if it fails
- See Also:
HomographyInducedStereo3Pts
-
homographyStereoLinePt
public 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. Observations must be on the planar surface.- Parameters:
F- Fundamental matrixline- Line on the planepoint- Point on the plane- Returns:
- The homography from view 1 to view 2 or null if it fails
- See Also:
HomographyInducedStereoLinePt
-
homographyStereo2Lines
public 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. Observations must be on the planar surface.- Parameters:
F- Fundamental matrixline0- Line on the planeline1- Line on the plane- Returns:
- The homography from view 1 to view 2 or null if it fails
- See Also:
HomographyInducedStereo2Line
-
extractEpipoles
public 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:
- e2T*F12 = 0
- e3T*F13 = 0
- Parameters:
tensor- Trifocal tensor. Not Modifiede2- Output: Epipole in image 2. Homogeneous coordinates. Modifiede3- Output: Epipole in image 3. Homogeneous coordinates. Modified- See Also:
TrifocalExtractGeometries
-
extractFundamental
public 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.
- Parameters:
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.- See Also:
TrifocalExtractGeometries
-
extractCameraMatrices
public 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].
- Parameters:
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.- See Also:
TrifocalExtractGeometries
-
createEssential
public 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.- Parameters:
R- Rotation matrix.T- Translation vector.E- (Output) Storage for essential matrix. 3x3 matrix- Returns:
- Essential matrix
-
createFundamental
public 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. F = (K-1)T*E*K-1- Parameters:
E- Essential matrixK- Intrinsic camera calibration matrix- Returns:
- Fundamental matrix
-
createFundamental
public 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.- Parameters:
E- Essential matrixintrinsic- Intrinsic camera calibration- Returns:
- Fundamental matrix
- See Also:
createFundamental(DMatrixRMaj, DMatrixRMaj)
-
createFundamental
public 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. F = (K2-1)T*E*K1-1- Parameters:
E- Essential matrixK1- Intrinsic camera calibration matrix for camera 1K2- Intrinsic camera calibration matrix for camera 2- Returns:
- Fundamental matrix
-
createFundamental
public 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.
- Parameters:
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 matrix- Returns:
- Essential matrix
-
createHomography
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)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.- Parameters:
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.- Returns:
- Calibrated homography matrix
-
createHomography
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.- Parameters:
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 matrix- Returns:
- Uncalibrated homography matrix
-
extractEpipoles
public 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- Parameters:
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.
-
fundamentalToProjective
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
- Parameters:
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.- Returns:
- The canonical camera (projection) matrix P' (3 by 4) Known up to a projective transform.
- See Also:
extractEpipoles(boofcv.struct.geo.TrifocalTensor, georegression.struct.point.Point3D_F64, georegression.struct.point.Point3D_F64),FundamentalToProjective
-
projectiveToFundamental
public 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=0- Parameters:
P1- (Input) camera matrix for view 1P2- (Input) camera matrix for view 2F21- (Output) Fundamental matrix from view 1 to 2- Returns:
- Fundamental matrix.
-
fundamentalToProjective
public 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.- Parameters:
F- (Input) Fundamental Matrix- Returns:
- The canonical camera (projection) matrix P' (3 by 4) Known up to a projective transform.
- See Also:
FundamentalToProjective
-
fundamentalToEssential
public static org.ejml.data.DMatrixRMaj fundamentalToEssential(org.ejml.data.DMatrixRMaj F, org.ejml.data.DMatrixRMaj K, @Nullable org.ejml.data.DMatrixRMaj outputE)Given the calibration matrix, convert the fundamental matrix into an essential matrix. E = K'*F*k. The singular values of the resulting E matrix are forced to be [1,1,0]- Parameters:
F- (Input) Fundamental matrix. 3x3K- (Input) Calibration matrix (3x3)outputE- (Output) Found essential matrix- Returns:
- Essential matrix
-
fundamentalToProjective
public 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. Consistent means that the camera matrices will give back the same fundamental matrices, see [1]. This function is of dubious practical value, see discussion inFundamentalToProjective.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].- Page 301 in Y. Ma, S. Soatto, J. Kosecka, and S. S. Sastry, "An Invitation to 3-D Vision" Springer-Verlad, 2004
- Parameters:
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 3- See Also:
fundamentalCompatible3(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)
-
projectiveToIdentityH
public 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- Parameters:
P- (Input) camera matrix 3x4H- (Output) 4x4 matrix
-
fundamentalCompatible3
public 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
- Parameters:
F21- (Input) Fundamental matrix between view 1 and 2F31- (Input) Fundamental matrix between view 1 and 3F32- (Input) Fundamental matrix between view 2 and 3
-
decomposeMetricCamera
public 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.
- NOTE: There are multiple valid solutions to this problem and only one solution is returned.
- NOTE: The camera center will be on the plane at infinity.
- Parameters:
cameraMatrix- Input: Camera matrix, 3 by 4K- Output: Camera calibration matrix, 3 by 3.worldToView- Output: The rotation and translation.
-
decomposeEssential
public 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. Due to ambiguities there are four possible solutions. SeeDecomposeEssentialfor 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.- Parameters:
E21- An essential matrix.- Returns:
- Four possible motions. From view 1 to view 2.
- See Also:
DecomposeEssential
-
decomposeHomography
public 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). The homography is defined as H = (R + (1/d)*T*NT), where R is a 3x3 rotation matrix, d is the distance of the plane, N is the plane's normal (unit vector), T is the translation vector. If the homography is from view 'a' to 'b' then transform (R,T) will be from reference 'a' to 'b'. Note that the returned 'T' is divided by 'd'.- Parameters:
H- Homography in Euclidean space- Returns:
- The set of four possible solutions. First param: motion (R,T). Second param: plane normal vector.
- See Also:
DecomposeHomography
-
errorsHomographySymm
public 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')**2- Parameters:
observations- (Input) observationsH- (Input) HomographyH_inv- (Input) Inverse of homography. if null it will be computed internallystorage- (Output) storage for found errors
-
transfer_1_to_3
public 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)
Transfers a point from the first view to the third view using a plane induced by a line in the second view.- Parameters:
x1- (Input) point (pixel) in first viewl2- (Input) line in second viewT- (Input) Trifocal tensorx3- (Output) Induced point (pixel) in third view. Homogenous coordinates.- Returns:
- induced point.
-
transfer_1_to_3
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)
Transfers a point from the first view to the second view using the observed location in the third view- Parameters:
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.- Returns:
- induced point.
-
transfer_1_to_2
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)
Transfers a point from the first view to the second view using a plane induced by a line in the third view.- Parameters:
x1- (Input) point (pixel) in first viewl3- (Input) line in third viewT- (Input) Trifocal tensorx2- (Output) Induced point (pixel) in second view. Homogenous coordinates.- Returns:
- induced point.
-
transfer_1_to_2
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)
Transfers a point from the first view to the second view using the observed location in the third view- Parameters:
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.- Returns:
- induced point.
-
projectiveToMetric
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)Elevates a projective camera matrix into a metric one using the rectifying homography. Extracts calibration and Se3 pose.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- Parameters:
cameraMatrix- (Input) camera matrix. 3x4H- (Input) Rectifying homography. 4x4worldToView- (Output) Transform from world to camera viewK- (Output) Camera calibration matrix- See Also:
absoluteQuadraticToH(org.ejml.data.DMatrix4x4, org.ejml.data.DMatrixRMaj),decomposeMetricCamera(DMatrixRMaj, DMatrixRMaj, Se3_F64)
-
projectiveToMetricKnownK
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)Convert the projective camera matrix into a metric transform given the rectifying homography and a known calibration matrix.P = K*[R|T]*Hwhere H is the inverse of the rectifying homography.- Parameters:
cameraMatrix- (Input) camera matrix. 3x4H- (Input) Rectifying homography. 4x4K- (Input) Known calibration matrixworldToView- (Output) transform from world to camera view
-
enforceAbsoluteQuadraticConstraints
public 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. This forces the structure to match.- Positive diagonal elements
- (Optional) zero principle point
- (Optional) zero skew
- Q = H*diag([1 1 1 0])*HT and H = [K 0; -p'*K 1]
- R. Hartley, and A. Zisserman, "Multiple View Geometry in Computer Vision", 2nd Ed, Cambridge 2003
- Parameters:
Q- Approximate solution to absolute quadratic- See Also:
DecomposeAbsoluteDualQuadratic
-
absoluteQuadraticToH
public static boolean absoluteQuadraticToH(org.ejml.data.DMatrix4x4 Q, org.ejml.data.DMatrixRMaj H)Decomposes the absolute quadratic to extract the rectifying homogrpahy H. This is used to go from a projective to metric (calibrated) geometry. See pg 464 in [1].Q = H*I*HT
where I = diag(1 1 1 0)
- R. Hartley, and A. Zisserman, "Multiple View Geometry in Computer Vision", 2nd Ed, Cambridge 2003
- Parameters:
Q- (Input) Absolute quadratic. Typically found in auto calibration. Not modified.H- (Output) 4x4 rectifying homography.- See Also:
DecomposeAbsoluteDualQuadratic
-
rectifyHToAbsoluteQuadratic
public static void rectifyHToAbsoluteQuadratic(org.ejml.data.DMatrixRMaj H, org.ejml.data.DMatrixRMaj Q)Rectifying homography to dual absolute quadratic.Q = H*I*HT = H(:,1:3)*H(:,1:3)'
where I = diag(1 1 1 0)
- Parameters:
H- (Input) 4x4 rectifying homography.Q- (Output) Absolute quadratic. Typically found in auto calibration. Not modified.
-
intrinsicFromAbsoluteQuadratic
public 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.wi = Pi*Q*PiT, where wi = Ki*K'i
- Parameters:
Q- (Input) Dual absolute qudraticP- (Input) Camera matrix for a viewintrinsic- (Output) found intrinsic parameters
-
decomposeDiac
public 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). Elements which could cause problems if negative have the absolute value taken to avoid NaN. The upper triangular elements in w (DIAC) are passed in.- Parameters:
intrinsic- (output) K extracted from w
-
decomposeDiac
public static void decomposeDiac(org.ejml.data.DMatrixRMaj w, CameraPinhole intrinsic)Extracts the camera calibration matrix on the dual image of the absolute conic (DIAC). Elements which could cause problems if negative have the absolute value taken to avoid NaN.- Parameters:
w- (input) DIAC 3x3intrinsic- (output) K extracted from w
-
createProjectiveToMetric
public 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)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.H = [K 0;v' &lambda]
- Parameters:
K- 3x3 calibration matrix for view 1v1- plane at infinityv2- plane at infinityv3- plane at infinitylambda- scaling factorH- (Optional) Storage for 4x4 matrix- Returns:
- The homography
-
decomposeAbsDualQuadratic
public 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]- Parameters:
Q- (Input) Absolute quadratic. Typically found in auto calibration. Not modified.w- (Output) 3x3 symmetric matrixp- (Output) 3x1 vector- Returns:
- true if successful or false if it failed
- See Also:
DecomposeAbsoluteDualQuadratic
-
split2
public 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- Parameters:
input- List of associated features- Returns:
- two lists containing each set of features
-
split3
public 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- Parameters:
input- List of associated features- Returns:
- three lists containing each set of features
-
triangulatePoints
public static void triangulatePoints(SceneStructureMetric structure, SceneObservations observations)
Convience function for initializing bundle adjustment parameters. Triangulates points using camera position and pixel observations.- Parameters:
structure-observations-
-
-