当前位置: 首页>>代码示例>>Java>>正文


Java CommonOps.extract方法代码示例

本文整理汇总了Java中org.ejml.ops.CommonOps.extract方法的典型用法代码示例。如果您正苦于以下问题:Java CommonOps.extract方法的具体用法?Java CommonOps.extract怎么用?Java CommonOps.extract使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ejml.ops.CommonOps的用法示例。


在下文中一共展示了CommonOps.extract方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBasisVector

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
 * Returns a vector from the PCA's basis.
 *
 * @param which Which component's vector is to be returned.
 * @return Vector from the PCA basis.
 */
public double[] getBasisVector( int which ) {
    if( which < 0 || which >= numComponents )
        throw new IllegalArgumentException("Invalid component");

    DenseMatrix64F v = new DenseMatrix64F(1,A.numCols);
    CommonOps.extract(V_t,which,which+1,0,A.numCols,v,0,0);

    return v.data;
}
 
开发者ID:droiddeveloper1,项目名称:android-wear-gestures-recognition,代码行数:16,代码来源:PCA.java

示例2: getBasisVector

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
 * Returns a vector from the PCA's basis.
 *
 * @param which Which component's vector is to be returned.
 * @return Vector from the PCA basis.
 */
public double[] getBasisVector( int which ) {
   if( which < 0 || which >= numComponents )
      throw new IllegalArgumentException("Invalid component");

   DenseMatrix64F v = new DenseMatrix64F(1,A.numCols);
   CommonOps.extract(V_t,which,which+1,0,A.numCols,v,0,0);

   return v.data;
}
 
开发者ID:frank0631,项目名称:semantic-web-scraper,代码行数:16,代码来源:PrincipleComponentAnalysis.java

示例3: getBasisVector

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
 * Returns a vector from the PCA's basis.
 *
 * @param which Which component's vector is to be returned.
 * @return Vector from the PCA basis.
 */
public double[] getBasisVector(int which) {
    if (which < 0 || which >= getNumPrincipalComponents()) {
        throw new IllegalArgumentException("Invalid component");
    }

    DenseMatrix64F v = new DenseMatrix64F(1, getDataMatrix().numCols);
    CommonOps.extract(getPrincipalComponentSubspace(), which, which + 1, 0, getDataMatrix().numCols, v, 0, 0);

    return v.data;
}
 
开发者ID:LakkiB,项目名称:mlstorm,代码行数:17,代码来源:PrincipalComponentsBase.java

示例4: setupA

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
 * Sets up the system of equations which are to be solved.  This equation is derived from
 * constraints (3) and (4) in the paper.   See section 3.1.
 *
 * @param homographies set of observed homographies.
 */
private void setupA( List<DenseMatrix64F> homographies ) {
	A.reshape(2*homographies.size(),6, false);

	DenseMatrix64F h1 = new DenseMatrix64F(3,1);
	DenseMatrix64F h2 = new DenseMatrix64F(3,1);

	DenseMatrix64F v12 = new DenseMatrix64F(1,6);
	DenseMatrix64F v11 = new DenseMatrix64F(1,6);
	DenseMatrix64F v22 = new DenseMatrix64F(1,6);

	DenseMatrix64F v11m22 = new DenseMatrix64F(1,6);

	for( int i = 0; i < homographies.size(); i++ ) {
		DenseMatrix64F H = homographies.get(i);

		CommonOps.extract(H,0,3,0,1,h1,0,0);
		CommonOps.extract(H,0,3,1,2,h2,0,0);

		// normalize H by the max value to reduce numerical error when computing A
		// several numbers are multiplied against each other and could become quite large/small
		double max1 = CommonOps.elementMaxAbs(h1);
		double max2 = CommonOps.elementMaxAbs(h2);
		double max = Math.max(max1,max2);

		CommonOps.divide(max,h1);
		CommonOps.divide(max,h2);

		// compute elements of A
		computeV(h1, h2, v12);
		computeV(h1, h1, v11);
		computeV(h2, h2, v22);

		CommonOps.sub(v11,v22,v11m22);

		CommonOps.insert( v12    , A, i*2   , 0);
		CommonOps.insert( v11m22 , A, i*2+1 , 0);
	}
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:45,代码来源:Zhang99CalibrationMatrixFromHomographies.java

示例5: setupA_NoSkew

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
 * Similar to {@link #setupA(java.util.List)} but all references to B12 have been removed
 * since it will always be zero when the skew is zero
 *
 * @param homographies set of observed homographies.
 */
private void setupA_NoSkew( List<DenseMatrix64F> homographies ) {
	A.reshape(2*homographies.size(),5, false);

	DenseMatrix64F h1 = new DenseMatrix64F(3,1);
	DenseMatrix64F h2 = new DenseMatrix64F(3,1);

	DenseMatrix64F v12 = new DenseMatrix64F(1,5);
	DenseMatrix64F v11 = new DenseMatrix64F(1,5);
	DenseMatrix64F v22 = new DenseMatrix64F(1,5);

	DenseMatrix64F v11m22 = new DenseMatrix64F(1,5);

	for( int i = 0; i < homographies.size(); i++ ) {
		DenseMatrix64F H = homographies.get(i);

		CommonOps.extract(H,0,3,0,1,h1,0,0);
		CommonOps.extract(H,0,3,1,2,h2,0,0);

		// normalize H by the max value to reduce numerical error when computing A
		// several numbers are multiplied against each other and could become quite large/small
		double max1 = CommonOps.elementMaxAbs(h1);
		double max2 = CommonOps.elementMaxAbs(h2);
		double max = Math.max(max1,max2);

		CommonOps.divide(max,h1);
		CommonOps.divide(max,h2);

		// compute elements of A
		computeV_NoSkew(h1, h2, v12);
		computeV_NoSkew(h1, h1, v11);
		computeV_NoSkew(h2, h2, v22);

		CommonOps.sub(v11,v22,v11m22);

		CommonOps.insert( v12    , A, i*2   , 0);
		CommonOps.insert( v11m22 , A, i*2+1 , 0);
	}
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:45,代码来源:Zhang99CalibrationMatrixFromHomographies.java

示例6: computeHomography

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
 * Creates a homography as defined in Section 2.2 in Zhang99.
 *
 * H = K*[r1 r2 t]
 */
public static DenseMatrix64F computeHomography(DenseMatrix64F K, DenseMatrix64F R, Vector3D_F64 T)
{
	DenseMatrix64F M = new DenseMatrix64F(3,3);
	CommonOps.extract(R, 0, 3, 0, 1, M, 0, 0);
	CommonOps.extract(R, 0, 3, 1, 2, M, 0, 1);
	M.set(0, 2, T.x);
	M.set(1, 2, T.y);
	M.set(2, 2, T.z);

	DenseMatrix64F H = new DenseMatrix64F(3,3);
	CommonOps.mult(K,M,H);

	return H;
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:20,代码来源:GenericCalibrationGrid.java

示例7: process

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
 * Computes a trifocal tensor which minimizes the algebraic error given the
 * two epipoles and the linear constraint matrix.  The epipoles are from a previously
 * computed trifocal tensor.
 *
 * @param e2 Epipole of first image in the second image
 * @param e3 Epipole of first image in the third image
 * @param A Linear constraint matrix for trifocal tensor created from image observations.
 */
public void process( Point3D_F64 e2 , Point3D_F64 e3 , DenseMatrix64F A ) {
	// construct the linear system that the solution which solves the unknown square
	// matrices in the camera matrices
	constructE(e2, e3);

	// Computes U, which is used to map the 18 unknowns onto the 27 trifocal unknowns
	svdU.decompose(E);
	svdU.getU(U, false);

	// Copy the parts of U which correspond to the non singular parts if the SVD
	// since there are only really 18-nullity unknowns due to linear dependencies
	SingularOps.descendingOrder(U,false,svdU.getSingularValues(),svdU.numberOfSingularValues(),null,false);
	int rank = SingularOps.rank(svdU, 1e-13);
	Up.reshape(U.numRows,rank);
	CommonOps.extract(U,0,U.numRows,0,Up.numCols,Up,0,0);

	// project the linear constraint matrix into this subspace
	AU.reshape(A.numRows,Up.numCols);
	CommonOps.mult(A,Up,AU);

	// Extract the solution of ||A*U*x|| = 0 from the null space
	svdV.decompose(AU);

	xp.reshape(rank,1);
	SingularOps.nullVector(svdV,true,xp);

	// Translate the solution from the subspace and into a valid trifocal tensor
	CommonOps.mult(Up,xp,vectorT);

	// the sign of vectorT is arbitrary, but make it positive for consistency
	if( vectorT.data[0] > 0 )
		CommonOps.changeSign(vectorT);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:43,代码来源:EnforceTrifocalGeometry.java

示例8: decomposeCameraMatrix

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
 * <p>
 * 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.
 *
 * <ul>
 * <li> NOTE: There are multiple valid solutions to this problem and only one solution is returned.
 * <li> NOTE: The camera center will be on the plane at infinity.
 * </ul>
 * </p>
 *
 * @param P Input: Camera matrix, 3 by 4
 * @param K Output: Camera calibration matrix, 3 by 3.
 * @param pose Output: The rotation and translation.
 */
public static void decomposeCameraMatrix(DenseMatrix64F P, DenseMatrix64F K, Se3_F64 pose) {
	DenseMatrix64F KR = new DenseMatrix64F(3,3);
	CommonOps.extract(P, 0, 3, 0, 3, KR, 0, 0);

	QRDecomposition<DenseMatrix64F> qr = DecompositionFactory.qr(3, 3);

	if( !CommonOps.invert(KR) )
		throw new RuntimeException("Inverse failed!  Bad input?");

	if( !qr.decompose(KR) )
		throw new RuntimeException("QR decomposition failed!  Bad input?");

	DenseMatrix64F U = qr.getQ(null,false);
	DenseMatrix64F B = qr.getR(null, false);

	if( !CommonOps.invert(U,pose.getR()) )
		throw new RuntimeException("Inverse failed!  Bad input?");

	Point3D_F64 KT = new Point3D_F64(P.get(0,3),P.get(1,3),P.get(2,3));
	GeometryMath_F64.mult(B, KT, pose.getT());

	if( !CommonOps.invert(B,K) )
		throw new RuntimeException("Inverse failed!  Bad input?");

	CommonOps.scale(1.0/K.get(2,2),K);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:42,代码来源:MultiViewOps.java

示例9: canonicalCamera

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
@Test
public void canonicalCamera() {
	DenseMatrix64F K = PerspectiveOps.calibrationMatrix(200, 250, 0, 100, 110);
	DenseMatrix64F R = RotationMatrixGenerator.eulerXYZ(1,2,-0.5,null);
	Vector3D_F64 T = new Vector3D_F64(0.5,0.7,-0.3);

	DenseMatrix64F E = MultiViewOps.createEssential(R, T);
	DenseMatrix64F F = MultiViewOps.createFundamental(E, K);

	Point3D_F64 e1 = new Point3D_F64();
	Point3D_F64 e2 = new Point3D_F64();

	CommonOps.scale(-2.0/F.get(0,1),F);
	MultiViewOps.extractEpipoles(F, e1, e2);

	DenseMatrix64F P = MultiViewOps.canonicalCamera(F, e2, new Vector3D_F64(1, 1, 1), 2);

	// recompose the fundamental matrix using the special equation for canonical cameras
	DenseMatrix64F foundF = new DenseMatrix64F(3,3);
	DenseMatrix64F crossEpi = new DenseMatrix64F(3,3);

	GeometryMath_F64.crossMatrix(e2, crossEpi);

	DenseMatrix64F M = new DenseMatrix64F(3,3);
	CommonOps.extract(P,0,3,0,3,M,0,0);
	CommonOps.mult(crossEpi,M,foundF);

	// see if they are equal up to a scale factor
	CommonOps.scale(1.0 / foundF.get(0, 1), foundF);
	CommonOps.scale(1.0 / F.get(0, 1), F);

	assertTrue(MatrixFeatures.isIdentical(F,foundF,1e-8));
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:34,代码来源:TestMultiViewOps.java


注:本文中的org.ejml.ops.CommonOps.extract方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。