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 org.ejml.data.DenseMatrix64F |
canonicalCamera(org.ejml.data.DenseMatrix64F F,
georegression.struct.point.Point3D_F64 e2,
georegression.struct.point.Vector3D_F64 v,
double lambda)
Given a fundamental matrix a pair of projection matrices [R|T] can be extracted.
|
static double |
constraint(org.ejml.data.DenseMatrix64F 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.DenseMatrix64F |
constraint(TrifocalTensor tensor,
georegression.struct.point.Point2D_F64 p1,
georegression.struct.point.Point2D_F64 p2,
georegression.struct.point.Point2D_F64 p3,
org.ejml.data.DenseMatrix64F 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.DenseMatrix64F 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.DenseMatrix64F |
createEssential(org.ejml.data.DenseMatrix64F R,
georegression.struct.point.Vector3D_F64 T)
Computes an essential matrix from a rotation and translation.
|
static org.ejml.data.DenseMatrix64F |
createFundamental(org.ejml.data.DenseMatrix64F E,
org.ejml.data.DenseMatrix64F K)
Computes a Fundamental matrix given an Essential matrix and the camera calibration matrix.
|
static org.ejml.data.DenseMatrix64F |
createFundamental(org.ejml.data.DenseMatrix64F E,
org.ejml.data.DenseMatrix64F K1,
org.ejml.data.DenseMatrix64F K2)
Computes a Fundamental matrix given an Essential matrix and the camera calibration matrix.
|
static org.ejml.data.DenseMatrix64F |
createHomography(org.ejml.data.DenseMatrix64F 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:
H = R+(1/d)*T*NT |
static org.ejml.data.DenseMatrix64F |
createHomography(org.ejml.data.DenseMatrix64F R,
georegression.struct.point.Vector3D_F64 T,
double d,
georegression.struct.point.Vector3D_F64 N,
org.ejml.data.DenseMatrix64F K)
Computes a homography matrix from a rotation, translation, plane normal, plane distance, and
calibration matrix:
H = K*(R+(1/d)*T*NT)*K-1 |
static TrifocalTensor |
createTrifocal(org.ejml.data.DenseMatrix64F P2,
org.ejml.data.DenseMatrix64F 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 void |
decomposeCameraMatrix(org.ejml.data.DenseMatrix64F P,
org.ejml.data.DenseMatrix64F K,
georegression.struct.se.Se3_F64 pose)
Decomposes a camera matrix P=A*[R|T], where A is an upper triangular camera calibration
matrix, R is a rotation matrix, and T is a translation vector.
|
static java.util.List<georegression.struct.se.Se3_F64> |
decomposeEssential(org.ejml.data.DenseMatrix64F E)
Decomposes an essential matrix into the rigid body motion which it was constructed from.
|
static java.util.List<boofcv.struct.Tuple2<georegression.struct.se.Se3_F64,georegression.struct.point.Vector3D_F64>> |
decomposeHomography(org.ejml.data.DenseMatrix64F H)
Decomposes a homography matrix that's in Euclidean space (computed from features in normalized image coordinates).
|
static void |
extractCameraMatrices(TrifocalTensor tensor,
org.ejml.data.DenseMatrix64F P2,
org.ejml.data.DenseMatrix64F P3)
Extract the camera matrices up to a common projective transform.
|
static void |
extractEpipoles(org.ejml.data.DenseMatrix64F 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.DenseMatrix64F F2,
org.ejml.data.DenseMatrix64F F3)
Extract the fundamental matrices between views 1 + 2 and views 1 + 3.
|
static org.ejml.data.DenseMatrix64F |
homographyStereo2Lines(org.ejml.data.DenseMatrix64F 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.DenseMatrix64F |
homographyStereo3Pts(org.ejml.data.DenseMatrix64F 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.DenseMatrix64F |
homographyStereoLinePt(org.ejml.data.DenseMatrix64F 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.DenseMatrix64F |
inducedHomography12(TrifocalTensor tensor,
georegression.struct.point.Vector3D_F64 line3,
org.ejml.data.DenseMatrix64F output)
Computes the homography induced from view 1 to 2 by a line in view 3.
|
static org.ejml.data.DenseMatrix64F |
inducedHomography13(TrifocalTensor tensor,
georegression.struct.point.Vector3D_F64 line2,
org.ejml.data.DenseMatrix64F output)
Computes the homography induced from view 1 to 3 by a line in view 2.
|
public static TrifocalTensor createTrifocal(org.ejml.data.DenseMatrix64F P2, org.ejml.data.DenseMatrix64F P3, TrifocalTensor ret)
Creates a trifocal tensor from two camera matrices.
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 from view 1 to view 2P3 - Camera matrix from view 1 to view 3ret - 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, 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.
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, 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.DenseMatrix64F constraint(TrifocalTensor tensor, georegression.struct.point.Point2D_F64 p1, georegression.struct.point.Point2D_F64 p2, georegression.struct.point.Point2D_F64 p3, org.ejml.data.DenseMatrix64F 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.DenseMatrix64F 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.DenseMatrix64F 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.DenseMatrix64F inducedHomography13(TrifocalTensor tensor, georegression.struct.point.Vector3D_F64 line2, org.ejml.data.DenseMatrix64F output)
tensor - Input: Trifocal tensorline2 - Input: Line in view 2. General notation.output - Output: Optional storage for homography. 3x3 matrixpublic static org.ejml.data.DenseMatrix64F inducedHomography12(TrifocalTensor tensor, georegression.struct.point.Vector3D_F64 line3, org.ejml.data.DenseMatrix64F output)
tensor - Input: Trifocal tensorline3 - Input: Line in view 3. General notation.output - Output: Optional storage for homography. 3x3 matrixpublic static org.ejml.data.DenseMatrix64F homographyStereo3Pts(org.ejml.data.DenseMatrix64F F,
AssociatedPair p1,
AssociatedPair p2,
AssociatedPair p3)
F - Fundamental matrixp1 - Associated point observationp2 - Associated point observationp3 - Associated point observationHomographyInducedStereo3Ptspublic static org.ejml.data.DenseMatrix64F homographyStereoLinePt(org.ejml.data.DenseMatrix64F F,
PairLineNorm line,
AssociatedPair point)
F - Fundamental matrixline - Line on the planepoint - Point on the planeHomographyInducedStereoLinePtpublic static org.ejml.data.DenseMatrix64F homographyStereo2Lines(org.ejml.data.DenseMatrix64F 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. ModifiedTrifocalExtractEpipolespublic static void extractFundamental(TrifocalTensor tensor, org.ejml.data.DenseMatrix64F F2, org.ejml.data.DenseMatrix64F F3)
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.F2 - Output: Fundamental matrix for views 1 and 2. Modified.F3 - Output: Fundamental matrix for views 1 and 3. Modified.public static void extractCameraMatrices(TrifocalTensor tensor, org.ejml.data.DenseMatrix64F P2, org.ejml.data.DenseMatrix64F 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.public static org.ejml.data.DenseMatrix64F createEssential(org.ejml.data.DenseMatrix64F R,
georegression.struct.point.Vector3D_F64 T)
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.public static org.ejml.data.DenseMatrix64F createFundamental(org.ejml.data.DenseMatrix64F E,
org.ejml.data.DenseMatrix64F K)
E - Essential matrixK - Intrinsic camera calibration matrixpublic static org.ejml.data.DenseMatrix64F createFundamental(org.ejml.data.DenseMatrix64F E,
org.ejml.data.DenseMatrix64F K1,
org.ejml.data.DenseMatrix64F K2)
E - Essential matrixK1 - Intrinsic camera calibration matrix for camera 1K2 - Intrinsic camera calibration matrix for camera 2public static org.ejml.data.DenseMatrix64F createHomography(org.ejml.data.DenseMatrix64F 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:
H = R+(1/d)*T*NT
R - Rotation matrix.T - Translation vector.d - Distance of closest point on plane to cameraN - Normal of planepublic static org.ejml.data.DenseMatrix64F createHomography(org.ejml.data.DenseMatrix64F R,
georegression.struct.point.Vector3D_F64 T,
double d,
georegression.struct.point.Vector3D_F64 N,
org.ejml.data.DenseMatrix64F K)
Computes a homography matrix from a rotation, translation, plane normal, plane distance, and
calibration matrix:
H = K*(R+(1/d)*T*NT)*K-1
R - Rotation matrix.T - Translation vector.d - Distance of closest point on plane to cameraN - Normal of planeK - Intrinsic calibration matrixpublic static void extractEpipoles(org.ejml.data.DenseMatrix64F 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.DenseMatrix64F canonicalCamera(org.ejml.data.DenseMatrix64F F,
georegression.struct.point.Point3D_F64 e2,
georegression.struct.point.Vector3D_F64 v,
double lambda)
Given a fundamental matrix a pair of projection matrices [R|T] can be extracted. There are multiple
solutions which can be found, the canonical projection 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.
Page 256 in R. Hartley, and A. Zisserman, "Multiple View Geometry in Computer Vision", 2nd Ed, Cambridge 2003
F - A fundamental matrixv - Arbitrary 3-vector. Just pick some value, say (1,1,1).lambda - A non zero scalar. Try one.e2 - Left epipole of fundamental matrix, FT*e2 = 0.extractEpipoles(boofcv.struct.geo.TrifocalTensor, georegression.struct.point.Point3D_F64, georegression.struct.point.Point3D_F64)public static void decomposeCameraMatrix(org.ejml.data.DenseMatrix64F P,
org.ejml.data.DenseMatrix64F K,
georegression.struct.se.Se3_F64 pose)
Decomposes a camera matrix P=A*[R|T], where A is an upper triangular camera calibration matrix, R is a rotation matrix, and T is a translation vector.
P - Input: Camera matrix, 3 by 4K - Output: Camera calibration matrix, 3 by 3.pose - Output: The rotation and translation.public static java.util.List<georegression.struct.se.Se3_F64> decomposeEssential(org.ejml.data.DenseMatrix64F E)
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.E - An essential matrix.DecomposeEssentialpublic static java.util.List<boofcv.struct.Tuple2<georegression.struct.se.Se3_F64,georegression.struct.point.Vector3D_F64>> decomposeHomography(org.ejml.data.DenseMatrix64F H)
H - Homography in Euclidean spaceDecomposeHomography