// 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;
		proj_matrix[15] = 0;
	}
	
	// for debugging
	public static void glIdentityMatrix(double[] m){
		m[0] = 1;
		m[1] = 0;
		m[2] = 0;
		m[3] = 0;
		m[4] = 0;
		m[5] = 1;
		m[6] = 0;
		m[7] = 0;
		m[8] = 0;
		m[9] = 0;
		m[10] = 1;
		m[11] = 0;
		m[12] = 0;
		m[13] = 0;
		m[14] = -5;
		m[15] = 1;
	}
	
	// default invert = false
    public static void glGetProjectionMatrix(CameraParameters cp, Size orgImgSize, Size size, double proj_matrix[],
    		double gnear, double gfar) throws CPException, ExtParamException{	
    	glGetProjectionMatrix(cp, orgImgSize, size, proj_matrix, gnear, gfar, false);
    }
    
    public static void glGetProjectionMatrix(CameraParameters cp, Size orgImgSize, Size size, double proj_matrix[],
// 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;

		proj_matrix[15] = 0;
	}
	
	// for debugging
	public static void glIdentityMatrix(double[] m){
		m[0] = 1;
		m[1] = 0;
		m[2] = 0;
		m[3] = 0;
		m[4] = 0;
		m[5] = 1;
		m[6] = 0;
		m[7] = 0;
		m[8] = 0;
		m[9] = 0;
		m[10] = 1;
		m[11] = 0;
		m[12] = 0;
		m[13] = 0;
		m[14] = -5;
		m[15] = 1;
	}
	
	// default invert = false
    public static void glGetProjectionMatrix(CameraParameters cp, Size orgImgSize, Size size, double proj_matrix[],
    		double gnear, double gfar) throws CPException, ExtParamException{	
    	glGetProjectionMatrix(cp, orgImgSize, size, proj_matrix, gnear, gfar, false);
    }
    
    public static void glGetProjectionMatrix(CameraParameters cp, Size orgImgSize, Size size, double proj_matrix[],
    		double gnear, double gfar, boolean invert) throws CPException, ExtParamException{