// Path: openCVTutorial1CameraPreview/src/main/java/es/ava/aruco/exceptions/CPException.java
// public class CPException extends Exception{
// 
// 	private static final long serialVersionUID = 1L;
// 	private String message;
// 
// 	public CPException(String string) {
// 		message = string;
// 	}
// 	
// 	public String getMessage(){
// 		return message;
// 	}
// }
// 
// Path: openCVTutorial1CameraPreview/src/main/java/es/ava/aruco/exceptions/ExtParamException.java
// public class ExtParamException extends Exception{
// 
// 	private static final long serialVersionUID = 1L;
// 	private String message;
// 	
// 	public ExtParamException(String string){
// 		message = string;
// 	}
// 	
// 	public String getMessage(){
// 		return message;
// 	}
// }


import android.util.Log;
import java.util.List;
import java.util.Vector;
import org.opencv.calib3d.Calib3d;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.MatOfPoint2f;
import org.opencv.core.MatOfPoint3f;
import org.opencv.core.Point;
import org.opencv.core.Point3;
import org.opencv.core.Scalar;
import org.opencv.core.Size;
import org.opencv.imgproc.Imgproc;
import org.opencv.utils.Converters;
import es.ava.aruco.exceptions.CPException;
import es.ava.aruco.exceptions.ExtParamException;
	    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);
	}
	
	public static void myProjectionMatrix(CameraParameters cp, Size size,
// Path: openCVTutorial1CameraPreview/src/main/java/es/ava/aruco/exceptions/CPException.java
// public class CPException extends Exception{
// 
// 	private static final long serialVersionUID = 1L;
// 	private String message;
// 
// 	public CPException(String string) {
// 		message = string;
// 	}
// 	
// 	public String getMessage(){
// 		return message;
// 	}
// }
// 
// Path: openCVTutorial1CameraPreview/src/main/java/es/ava/aruco/exceptions/ExtParamException.java
// public class ExtParamException extends Exception{
// 
// 	private static final long serialVersionUID = 1L;
// 	private String message;
// 	
// 	public ExtParamException(String string){
// 		message = string;
// 	}
// 	
// 	public String getMessage(){
// 		return message;
// 	}
// }


// Path: openCVTutorial1CameraPreview/src/main/java/es/ava/aruco/Utils.java
import android.util.Log;
import java.util.List;
import java.util.Vector;
import org.opencv.calib3d.Calib3d;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.MatOfPoint2f;
import org.opencv.core.MatOfPoint3f;
import org.opencv.core.Point;
import org.opencv.core.Point3;
import org.opencv.core.Scalar;
import org.opencv.core.Size;
import org.opencv.imgproc.Imgproc;
import org.opencv.utils.Converters;
import es.ava.aruco.exceptions.CPException;
import es.ava.aruco.exceptions.ExtParamException;

	    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);
	}
	
	public static void myProjectionMatrix(CameraParameters cp, Size size,
			double proj_matrix[], double gnear, double gfar) throws CPException, ExtParamException{