List of usage examples for org.opencv.calib3d Calib3d calibrateCamera
public static double calibrateCamera(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, int flags)
From source file:de.vion.eyetracking.cameracalib.calibration.opencv.CameraCalibrator.java
public void calibrate() { ArrayList<Mat> rvecs = new ArrayList<Mat>(); ArrayList<Mat> tvecs = new ArrayList<Mat>(); Mat reprojectionErrors = new Mat(); ArrayList<Mat> objectPoints = new ArrayList<Mat>(); objectPoints.add(Mat.zeros(this.mCornersSize, 1, CvType.CV_32FC3)); calcBoardCornerPositions(objectPoints.get(0)); for (int i = 1; i < this.mCornersBuffer.size(); i++) { objectPoints.add(objectPoints.get(0)); }/* w ww . j av a2 s . c o m*/ Calib3d.calibrateCamera(objectPoints, this.mCornersBuffer, this.mImageSize, this.mCameraMatrix, this.mDistortionCoefficients, rvecs, tvecs, this.mFlags); this.mIsCalibrated = Core.checkRange(this.mCameraMatrix) && Core.checkRange(this.mDistortionCoefficients); this.mRms = computeReprojectionErrors(objectPoints, rvecs, tvecs, reprojectionErrors); }
From source file:org.usfirst.frc.team2084.CMonster2016.vision.CameraCalibration.java
License:Open Source License
/** * Calibrate the camera. This goes through all the corners in the list and * calibrates based off them./* ww w . j av a2 s . co m*/ * * @return the reprojection error */ public double calibrate() { cameraMatrix = Mat.eye(3, 3, CvType.CV_64F); distCoeffs = new MatOfDouble(Mat.zeros(8, 1, CvType.CV_64F)); List<Mat> rvecs = new LinkedList<>(); List<Mat> tvecs = new LinkedList<>(); // Set the fixed aspect ratio cameraMatrix.put(0, 0, aspectRatio); List<Mat> objectPoints = Collections.nCopies(calibrationCorners.size(), calcBoardCornerPositions()); System.out.println(cameraMatrix); return error = Calib3d.calibrateCamera(objectPoints, calibrationCorners, HighGoalProcessor.IMAGE_SIZE, cameraMatrix, distCoeffs, rvecs, tvecs, Calib3d.CALIB_FIX_PRINCIPAL_POINT); }