/** * <p> * Applies the epipolar relationship constraint to an essential or fundamental matrix:<br> * 0 = p2<sup>T</sup>*F*p1<br> * Input points are in normalized image coordinates for an essential matrix and pixels for * fundamental. * </p> * * @param F 3x3 essential or fundamental matrix. * @param p1 Point in view 1. * @param p2 Point in view 2. * @return Constraint value. */ public static double constraint( DMatrixRMaj F , Point2D_F64 p1, Point2D_F64 p2 ) { return GeometryMath_F64.innerProd(p2,F,p1); }
/** * <p> * Applies the epipolar relationship constraint to an essential or fundamental matrix:<br> * 0 = p2<sup>T</sup>*F*p1<br> * Input points are in normalized image coordinates for an essential matrix and pixels for * fundamental. * </p> * * @param F 3x3 essential or fundamental matrix. * @param p1 Point in view 1. * @param p2 Point in view 2. * @return Constraint value. */ public static double constraint( DenseMatrix64F F , Point2D_F64 p1, Point2D_F64 p2 ) { return GeometryMath_F64.innerProd(p2,F,p1); }
@Override public double computeDistance(AssociatedPair pt) { return Math.abs(GeometryMath_F64.innerProd(pt.p2, M, pt.p1)); }
@Override public double computeDistance(AssociatedPair pt) { return Math.abs(GeometryMath_F64.innerProd(pt.p2, M, pt.p1)); }
/** * Since the sign of the homography is ambiguous a point is required to make sure the correct * one was selected. * * @param p test point, used to determine the sign of the matrix. */ protected void adjustHomographSign( AssociatedPair p , DMatrixRMaj H ) { double val = GeometryMath_F64.innerProd(p.p2, H, p.p1); if( val < 0 ) CommonOps_DDRM.scale(-1, H); }
/** * Since the sign of the homography is ambiguous a point is required to make sure the correct * one was selected. * * @param p test point, used to determine the sign of the matrix. */ protected void adjustHomographSign( AssociatedPair p , DenseMatrix64F H ) { double val = GeometryMath_F64.innerProd(p.p2, H, p.p1); if( val < 0 ) CommonOps.scale(-1, H); }
/** * <p> * Trifocal tensor with line-line-line correspondence:<br> * (l2<sup>T</sup>*[T1,T2,T3]*L2)*[l1]<sub>x</sub> = 0 * </p> * * @param tensor Trifocal tensor * @param l1 A line in the first view. * @param l2 A line in the second view. * @param l3 A line in the third view. * @param ret Storage for output. If null a new instance will be declared. * @return Result of applying the constraint. With perfect inputs will be zero. */ public static Vector3D_F64 constraint(TrifocalTensor tensor, Vector3D_F64 l1, Vector3D_F64 l2, Vector3D_F64 l3, Vector3D_F64 ret) { if( ret == null ) ret = new Vector3D_F64(); double x = GeometryMath_F64.innerProd(l2, tensor.T1, l3); double y = GeometryMath_F64.innerProd(l2, tensor.T2, l3); double z = GeometryMath_F64.innerProd(l2, tensor.T3, l3); GeometryMath_F64.cross(new Vector3D_F64(x, y, z), l1, ret); return ret; }
/** * <p> * Trifocal tensor with line-line-line correspondence:<br> * (l2<sup>T</sup>*[T1,T2,T3]*L2)*[l1]<sub>x</sub> = 0 * </p> * * @param tensor Trifocal tensor * @param l1 A line in the first view. * @param l2 A line in the second view. * @param l3 A line in the third view. * @param ret Storage for output. If null a new instance will be declared. * @return Result of applying the constraint. With perfect inputs will be zero. */ public static Vector3D_F64 constraint(TrifocalTensor tensor, Vector3D_F64 l1, Vector3D_F64 l2, Vector3D_F64 l3, @Nullable Vector3D_F64 ret) { if( ret == null ) ret = new Vector3D_F64(); double x = GeometryMath_F64.innerProd(l2, tensor.T1, l3); double y = GeometryMath_F64.innerProd(l2, tensor.T2, l3); double z = GeometryMath_F64.innerProd(l2, tensor.T3, l3); GeometryMath_F64.cross(new Vector3D_F64(x, y, z), l1, ret); return ret; }
/** * Since the sign of the homography is ambiguous a point is required to make sure the correct * one was selected. * * @param p test point, used to determine the sign of the matrix. */ protected void adjustHomographSign( PairLineNorm p , DMatrixRMaj H ) { CommonOps_DDRM.transpose(H,H_t); double val = GeometryMath_F64.innerProd(p.l1, H_t, p.l2); if( val < 0 ) CommonOps_DDRM.scale(-1, H); } }
/** * Since the sign of the homography is ambiguous a point is required to make sure the correct * one was selected. * * @param p test point, used to determine the sign of the matrix. */ protected void adjustHomographSign( PairLineNorm p , DenseMatrix64F H ) { CommonOps.transpose(H,H_t); double val = GeometryMath_F64.innerProd(p.l1, H_t, p.l2); if( val < 0 ) CommonOps.scale(-1, H); } }
/** * <p> * Trifocal tensor with point-line-line correspondence:<br> * (l2<sup>T</sup>*(sum p1<sup>i</sup>*T<sub>i</sub>)*l3 = 0 * </p> * * @param tensor Trifocal tensor * @param p1 A point in the first view. * @param l2 A line in the second view. * @param l3 A line in the third view. * @return Result of applying the constraint. With perfect inputs will be zero. */ public static double constraint(TrifocalTensor tensor, Point2D_F64 p1, Vector3D_F64 l2, Vector3D_F64 l3) { DenseMatrix64F sum = new DenseMatrix64F(3,3); CommonOps.add(p1.x,tensor.T1,sum,sum); CommonOps.add(p1.y,tensor.T2,sum,sum); CommonOps.add(tensor.T3, sum, sum); return GeometryMath_F64.innerProd(l2,sum,l3); }
/** * <p> * Trifocal tensor with point-line-line correspondence:<br> * (l2<sup>T</sup>*(sum p1<sup>i</sup>*T<sub>i</sub>)*l3 = 0 * </p> * * @param tensor Trifocal tensor * @param p1 A point in the first view. * @param l2 A line in the second view. * @param l3 A line in the third view. * @return Result of applying the constraint. With perfect inputs will be zero. */ public static double constraint(TrifocalTensor tensor, Point2D_F64 p1, Vector3D_F64 l2, Vector3D_F64 l3) { DMatrixRMaj sum = new DMatrixRMaj(3,3); CommonOps_DDRM.add(p1.x,tensor.T1,sum,sum); CommonOps_DDRM.add(p1.y,tensor.T2,sum,sum); CommonOps_DDRM.add(tensor.T3, sum, sum); return GeometryMath_F64.innerProd(l2,sum,l3); }