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


Java Calib3d.Rodrigues方法代码示例

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


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

示例1: rotateXAxis

import org.opencv.calib3d.Calib3d; //导入方法依赖的package包/类
protected static void rotateXAxis(Mat rotation){
	// get the matrix corresponding to the rotation vector
	Mat R = new Mat(3,3,CvType.CV_64FC1);
	Calib3d.Rodrigues(rotation, R);
    
	// create the matrix to rotate 90º around the X axis
    // 1, 0, 0
    // 0 cos -sin
    // 0 sin cos
	double[] rot = {
			1, 0,  0,
			0, 0, -1,
			0, 1, 0
	};
	// multiply both matrix
	Mat res = new Mat(3,3, CvType.CV_64FC1);
	double[] prod = new double[9];
	double[] a = new double[9];
	R.get(0, 0, a);
       for(int i=0;i<3;i++)
           for(int j=0;j<3;j++){
           	prod[3*i+j] = 0;
               for(int k=0;k<3;k++){
               	prod[3*i+j] += a[3*i+k]*rot[3*k+j];
               }
           }
       // convert the matrix to a vector with rodrigues back
       res.put(0, 0, prod);
	Calib3d.Rodrigues(res, rotation);
}
 
开发者ID:davrempe,项目名称:cardboardAR-lib,代码行数:31,代码来源:Utils.java

示例2: alignToId

import org.opencv.calib3d.Calib3d; //导入方法依赖的package包/类
protected static void alignToId(Mat rotation, int codeRotation) {
	//get the matrix corresponding to the rotation vector
	Mat R = new Mat(3, 3, CvType.CV_64FC1);
	Calib3d.Rodrigues(rotation, R);

	if (codeRotation != 3) {
		codeRotation += 1;
		rotateZAxis(rotation, codeRotation * -90.0);
	}
}
 
开发者ID:davrempe,项目名称:cardboardAR-lib,代码行数:11,代码来源:Utils.java

示例3: rotateZAxis

import org.opencv.calib3d.Calib3d; //导入方法依赖的package包/类
protected static void rotateZAxis(Mat rotation, double rotateDegrees) {
	// get the matrix corresponding to the rotation vector
	Mat R = new Mat(3,3,CvType.CV_64FC1);
	Calib3d.Rodrigues(rotation, R);

	// create the matrix to rotate around the Z axis
	// cos -sin  0
	// sin  cos  0
	// 0    0    1
	double[] rot = {
			Math.cos(Math.toRadians(rotateDegrees)), -Math.sin(Math.toRadians(rotateDegrees)), 0,
			Math.sin(Math.toRadians(rotateDegrees)), Math.cos(Math.toRadians(rotateDegrees)), 0,
			0,0,1
	};
	// multiply both matrix
	Mat res = new Mat(3,3, CvType.CV_64FC1);
	double[] prod = new double[9];
	double[] a = new double[9];
	R.get(0, 0, a);
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++){
			prod[3*i+j] = 0;
			for(int k=0;k<3;k++){
				prod[3*i+j] += a[3*i+k]*rot[3*k+j];
			}
		}
	// convert the matrix to a vector with rodrigues back
	res.put(0, 0, prod);
	Calib3d.Rodrigues(res, rotation);
}
 
开发者ID:davrempe,项目名称:cardboardAR-lib,代码行数:31,代码来源:Utils.java

示例4: rotateXAxis

import org.opencv.calib3d.Calib3d; //导入方法依赖的package包/类
/**
 * Rotates a matrix around the X axis by the desired amount
 * @param rotation The matrix to be rotated
 * @param rotateDegrees The amount to rotate in degrees
 */
public static void rotateXAxis(Mat rotation, double rotateDegrees) {
    // get the matrix corresponding to the rotation vector
    Mat R = new Mat(3, 3, CvType.CV_64FC1);
    Calib3d.Rodrigues(rotation, R);

    // create the matrix to rotate around the X axis
    // 1, 0, 0
    // 0 cos -sin
    // 0 sin cos
    double[] rot = {
            1, 0, 0,
            0, Math.cos(Math.toRadians(rotateDegrees)), -Math.sin(Math.toRadians(rotateDegrees)),
            0, Math.sin(Math.toRadians(rotateDegrees)), Math.cos(Math.toRadians(rotateDegrees))
    };
    // multiply both matrix
    Mat res = new Mat(3, 3, CvType.CV_64FC1);
    double[] prod = new double[9];
    double[] a = new double[9];
    R.get(0, 0, a);
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++) {
            prod[3 * i + j] = 0;
            for (int k = 0; k < 3; k++) {
                prod[3 * i + j] += a[3 * i + k] * rot[3 * k + j];
            }
        }
    // convert the matrix to a vector with rodrigues back
    res.put(0, 0, prod);
    Calib3d.Rodrigues(res, rotation);
}
 
开发者ID:davrempe,项目名称:cardboardAR-lib,代码行数:36,代码来源:CVUtil.java

示例5: rotateYAxis

import org.opencv.calib3d.Calib3d; //导入方法依赖的package包/类
/**
 * Rotates a matrix around the Y axis by the desired amount
 * @param rotation The matrix to be rotated
 * @param rotateDegrees The amount to rotate in degrees
 */
public static void rotateYAxis(Mat rotation, double rotateDegrees) {
    // get the matrix corresponding to the rotation vector
    Mat R = new Mat(3,3,CvType.CV_64FC1);
    Calib3d.Rodrigues(rotation, R);

    // create the matrix to rotate around the Y axis
    // cos 0 sin
    // 0   1  0
    //-sin 0 cos
    double[] rot = {
            Math.cos(Math.toRadians(rotateDegrees)), 0, Math.sin(Math.toRadians(rotateDegrees)),
            0,1,0,
            -Math.sin(Math.toRadians(rotateDegrees)), 0, Math.cos(Math.toRadians(rotateDegrees))
    };
    // multiply both matrix
    Mat res = new Mat(3,3, CvType.CV_64FC1);
    double[] prod = new double[9];
    double[] a = new double[9];
    R.get(0, 0, a);
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++){
            prod[3*i+j] = 0;
            for(int k=0;k<3;k++){
                prod[3*i+j] += a[3*i+k]*rot[3*k+j];
            }
        }
    // convert the matrix to a vector with rodrigues back
    res.put(0, 0, prod);
    Calib3d.Rodrigues(res, rotation);
}
 
开发者ID:davrempe,项目名称:cardboardAR-lib,代码行数:36,代码来源:CVUtil.java

示例6: rotateZAxis

import org.opencv.calib3d.Calib3d; //导入方法依赖的package包/类
/**
 * Rotates a matrix around the Z axis by the desired amount
 * @param rotation The matrix to be rotated
 * @param rotateDegrees The amount to rotate in degrees
 */
public static void rotateZAxis(Mat rotation, double rotateDegrees) {
    // get the matrix corresponding to the rotation vector
    Mat R = new Mat(3,3,CvType.CV_64FC1);
    Calib3d.Rodrigues(rotation, R);

    // create the matrix to rotate around the Z axis
    // cos -sin  0
    // sin  cos  0
    // 0    0    1
    double[] rot = {
            Math.cos(Math.toRadians(rotateDegrees)), -Math.sin(Math.toRadians(rotateDegrees)), 0,
            Math.sin(Math.toRadians(rotateDegrees)), Math.cos(Math.toRadians(rotateDegrees)), 0,
            0,0,1
    };
    // multiply both matrix
    Mat res = new Mat(3,3, CvType.CV_64FC1);
    double[] prod = new double[9];
    double[] a = new double[9];
    R.get(0, 0, a);
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++){
            prod[3*i+j] = 0;
            for(int k=0;k<3;k++){
                prod[3*i+j] += a[3*i+k]*rot[3*k+j];
            }
        }
    // convert the matrix to a vector with rodrigues back
    res.put(0, 0, prod);
    Calib3d.Rodrigues(res, rotation);
}
 
开发者ID:davrempe,项目名称:cardboardAR-lib,代码行数:36,代码来源:CVUtil.java

示例7: alignToId

import org.opencv.calib3d.Calib3d; //导入方法依赖的package包/类
protected static void alignToId(Mat rotation, int codeRotation) {
	//get the matrix corresponding to the rotation vector
	Mat R = new Mat(3, 3, CvType.CV_64FC1);
	Calib3d.Rodrigues(rotation, R);

	codeRotation += 1;
	rotateZAxis(rotation, codeRotation * 90);
}
 
开发者ID:jsmith613,项目名称:Aruco-Marker-Tracking-Android,代码行数:9,代码来源:Utils.java

示例8: rotateZAxis

import org.opencv.calib3d.Calib3d; //导入方法依赖的package包/类
/**
 * Rotates around Z axis by given amount
 * @param rotation Rvec to be changed
 * @param rotateDegrees degrees to be rotated
    */
protected static void rotateZAxis(Mat rotation, double rotateDegrees) {
	// get the matrix corresponding to the rotation vector
	Mat R = new Mat(3,3,CvType.CV_64FC1);
	Calib3d.Rodrigues(rotation, R);

	// create the matrix to rotate around the Z axis
	// cos -sin  0
	// sin  cos  0
	// 0    0    1
	double[] rot = {
			Math.cos(Math.toRadians(rotateDegrees)), -Math.sin(Math.toRadians(rotateDegrees)), 0,
			Math.sin(Math.toRadians(rotateDegrees)), Math.cos(Math.toRadians(rotateDegrees)), 0,
			0,0,1
	};
	// multiply both matrix
	Mat res = new Mat(3,3, CvType.CV_64FC1);
	double[] prod = new double[9];
	double[] a = new double[9];
	R.get(0, 0, a);
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++){
			prod[3*i+j] = 0;
			for(int k=0;k<3;k++){
				prod[3*i+j] += a[3*i+k]*rot[3*k+j];
			}
		}
	// convert the matrix to a vector with rodrigues back
	res.put(0, 0, prod);
	Calib3d.Rodrigues(res, rotation);
}
 
开发者ID:jsmith613,项目名称:Aruco-Marker-Tracking-Android,代码行数:36,代码来源:Utils.java

示例9: rotateXAxis

import org.opencv.calib3d.Calib3d; //导入方法依赖的package包/类
protected static void rotateXAxis(Mat rotation){
	// get the matrix corresponding to the rotation vector
	Mat R = new Mat(3,3,CvType.CV_64FC1);
	Calib3d.Rodrigues(rotation, R);
    
	// create the matrix to rotate 90° around the X axis
    // 1, 0, 0
    // 0 cos -sin
    // 0 sin cos
	double[] rot = {
			1, 0,  0,
			0, 0, -1,
			0, 1, 0
	};
	// multiply both matrix
	Mat res = new Mat(3,3, CvType.CV_64FC1);
	double[] prod = new double[9];
	double[] a = new double[9];
	R.get(0, 0, a);
       for(int i=0;i<3;i++)
           for(int j=0;j<3;j++){
           	prod[3*i+j] = 0;
               for(int k=0;k<3;k++){
               	prod[3*i+j] += a[3*i+k]*rot[3*k+j];
               }
           }
       // convert the matrix to a vector with rodrigues back
       res.put(0, 0, prod);
	Calib3d.Rodrigues(res, rotation);
}
 
开发者ID:jsmith613,项目名称:Aruco-Marker-Tracking-Android,代码行数:31,代码来源:Utils.java

示例10: glGetModelViewMatrix

import org.opencv.calib3d.Calib3d; //导入方法依赖的package包/类
public static void glGetModelViewMatrix(double[] modelview_matrix, Mat Rvec, Mat Tvec)throws ExtParamException{
	    //check if parameters are valid
	    boolean invalid=false;
	    double[] tvec = new double[3];
	    double[] rvec = new double[3];
	    
	    Rvec.get(0, 0, rvec);
	    Tvec.get(0, 0, tvec);

	    for (int i=0;i<3 && !invalid ;i++){
	        if (tvec[i] != -999999) invalid|=false;
	        if (rvec[i] != -999999) invalid|=false;
	    }
	    
	    if (invalid)
	    	throw new ExtParamException("extrinsic parameters are not set Marker.getModelViewMatrix");
	    Mat Rot = new Mat(3,3,CvType.CV_32FC1);
	    Mat Jacob = new Mat();
	    Calib3d.Rodrigues(Rvec, Rot, Jacob);// TODO jacob no se vuelve a usar

	    double[][] para = new double[3][4];
	    double[] rotvec = new double[9];
	    Rot.get(0,0,rotvec);
	    for (int i=0;i<3;i++)
	        for (int j=0;j<3;j++)
	        	para[i][j]=rotvec[3*i+j];
	    //now, add the translation
	    para[0][3]=tvec[0];
	    para[1][3]=tvec[1];
	    para[2][3]=tvec[2];
	    double scale=1;

	    // R1C2
	    modelview_matrix[0 + 0*4] = para[0][0];
	    modelview_matrix[0 + 1*4] = para[0][1];
	    modelview_matrix[0 + 2*4] = para[0][2];
	    modelview_matrix[0 + 3*4] = para[0][3];
	    // R2
	    modelview_matrix[1 + 0*4] = para[1][0];
	    modelview_matrix[1 + 1*4] = para[1][1];
	    modelview_matrix[1 + 2*4] = para[1][2];
	    modelview_matrix[1 + 3*4] = para[1][3];
	    // R3
	    modelview_matrix[2 + 0*4] = -para[2][0];
	    modelview_matrix[2 + 1*4] = -para[2][1];
	    modelview_matrix[2 + 2*4] = -para[2][2];
	    modelview_matrix[2 + 3*4] = -para[2][3];
	    
	    modelview_matrix[3 + 0*4] = 0.0f;
	    modelview_matrix[3 + 1*4] = 0.0f;
	    modelview_matrix[3 + 2*4] = 0.0f;
	    modelview_matrix[3 + 3*4] = 1.0f;
	    if (scale != 0.0)
	    {
	        modelview_matrix[12] *= scale;
	        modelview_matrix[13] *= scale;
	        modelview_matrix[14] *= scale;
	    }

	    // rotate 90º around the x axis
	    // rotating around x axis in OpenGL is equivalent to
	    // multiply the model matrix by the matrix:
	    // 1, 0, 0, 0, 0, cos(a), sin(a), 0, 0, -sin(a), cos(a), 0, 0, 0, 0, 1
//	    double[] auxRotMat = new double[]{
//	    	1, 0,  0, 0,
//	    	0, 0, 1, 0,
//	    	0, -1,  0, 0,
//	    	0, 0,  0, 1
//	    };
//	    Utils.matrixProduct(modelview_matrix1, auxRotMat, modelview_matrix);
	}
 
开发者ID:davrempe,项目名称:cardboardAR-lib,代码行数:72,代码来源:Utils.java

示例11: calculateCubeTvec

import org.opencv.calib3d.Calib3d; //导入方法依赖的package包/类
/**
 * Calculates the CubeTvec based on the input detected markers
 * @param detectedMarkers  input vector of the detected markers
 * @param paddingSize the size of the whitespace around the markers
 * @return the Tvec of the cube
 */
private static Mat calculateCubeTvec(Vector<Marker> detectedMarkers, float paddingSize) {

    //The center will be 1/2 markerSize + padding below each marker (-Z)
    Mat centerPoint = new Mat(3,1,CvType.CV_64FC1);
    centerPoint.put(0, 0, 0);
    centerPoint.put(1, 0, 0);
    centerPoint.put(2, 0, ((detectedMarkers.get(0).getSize() / 2) + paddingSize));

    //Setup Matrices and Variables
    Mat result = new Mat();
    double x = 0;
    double y = 0;
    double z = 0;

    for (int i = 0; i < detectedMarkers.size(); i++) {

        //Get Marker Rotation Matrix
        Mat rMat = new Mat(3, 3, CvType.CV_64FC1);
        Calib3d.Rodrigues(detectedMarkers.get(i).getRvec(), rMat);

        //Get Marker Translation Vector
        Mat markerTvec = new Mat();
        detectedMarkers.get(i).getTvec().convertTo(markerTvec, CvType.CV_64FC1);

        //Transform CenterPoint to Cube Coordinates using Matrix Multiplication
        Core.gemm(rMat, centerPoint, 1, markerTvec, 1, result, 0);

        //Add Coordinate Values to Total
        x += result.get(0, 0)[0];
        y += result.get(1, 0)[0];
        z += result.get(2, 0)[0];
    }

    //Average Coordinate Values
    x /= detectedMarkers.size();
    y /= detectedMarkers.size();
    z /= detectedMarkers.size();

    //Create, Populate, and Return cubeTvec
    Mat cubeTvec = new Mat(3,1,CvType.CV_64FC1);
    cubeTvec.put(0,0,x);
    cubeTvec.put(1,0,y);
    cubeTvec.put(2,0,z);
    return cubeTvec;
}
 
开发者ID:davrempe,项目名称:cardboardAR-lib,代码行数:52,代码来源:CubeDetector.java

示例12: glGetModelViewMatrix

import org.opencv.calib3d.Calib3d; //导入方法依赖的package包/类
protected static void glGetModelViewMatrix(double[] modelview_matrix, Mat Rvec, Mat Tvec)throws ExtParamException{
	    //check if parameters are valid
	    boolean invalid=false;
	    double[] tvec = new double[3];
	    double[] rvec = new double[3];
	    
	    Rvec.get(0, 0, rvec);
	    Tvec.get(0, 0, tvec);

	    for (int i=0;i<3 && !invalid ;i++){
	        if (tvec[i] != -999999) invalid|=false;
	        if (rvec[i] != -999999) invalid|=false;
	    }
	    
	    if (invalid)
	    	throw new ExtParamException("extrinsic parameters are not set Marker.getModelViewMatrix");
	    Mat Rot = new Mat(3,3,CvType.CV_32FC1);
	    Mat Jacob = new Mat();
	    Calib3d.Rodrigues(Rvec, Rot, Jacob);// TODO jacob no se vuelve a usar

	    double[][] para = new double[3][4];
	    double[] rotvec = new double[9];
	    Rot.get(0,0,rotvec);
	    for (int i=0;i<3;i++)
	        for (int j=0;j<3;j++)
	        	para[i][j]=rotvec[3*i+j];
	    //now, add the translation
	    para[0][3]=tvec[0];
	    para[1][3]=tvec[1];
	    para[2][3]=tvec[2];
	    double scale=1;

	    // R1C2
	    modelview_matrix[0 + 0*4] = para[0][0];
	    modelview_matrix[0 + 1*4] = para[0][1];
	    modelview_matrix[0 + 2*4] = para[0][2];
	    modelview_matrix[0 + 3*4] = para[0][3];
	    // R2
	    modelview_matrix[1 + 0*4] = para[1][0];
	    modelview_matrix[1 + 1*4] = para[1][1];
	    modelview_matrix[1 + 2*4] = para[1][2];
	    modelview_matrix[1 + 3*4] = para[1][3];
	    // R3
	    modelview_matrix[2 + 0*4] = -para[2][0];
	    modelview_matrix[2 + 1*4] = -para[2][1];
	    modelview_matrix[2 + 2*4] = -para[2][2];
	    modelview_matrix[2 + 3*4] = -para[2][3];
	    
	    modelview_matrix[3 + 0*4] = 0.0f;
	    modelview_matrix[3 + 1*4] = 0.0f;
	    modelview_matrix[3 + 2*4] = 0.0f;
	    modelview_matrix[3 + 3*4] = 1.0f;
	    if (scale != 0.0)
	    {
	        modelview_matrix[12] *= scale;
	        modelview_matrix[13] *= scale;
	        modelview_matrix[14] *= scale;
	    }

	    // rotate 90º around the x axis
	    // rotating around x axis in OpenGL is equivalent to
	    // multiply the model matrix by the matrix:
	    // 1, 0, 0, 0, 0, cos(a), sin(a), 0, 0, -sin(a), cos(a), 0, 0, 0, 0, 1
//	    double[] auxRotMat = new double[]{
//	    	1, 0,  0, 0,
//	    	0, 0, 1, 0,
//	    	0, -1,  0, 0,
//	    	0, 0,  0, 1
//	    };
//	    Utils.matrixProduct(modelview_matrix1, auxRotMat, modelview_matrix);
	}
 
开发者ID:jsmith613,项目名称:Aruco-Marker-Tracking-Android,代码行数:72,代码来源:Utils.java


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