Example usage for org.opencv.core MatOfPoint3f MatOfPoint3f

List of usage examples for org.opencv.core MatOfPoint3f MatOfPoint3f

Introduction

In this page you can find the example usage for org.opencv.core MatOfPoint3f MatOfPoint3f.

Prototype

public MatOfPoint3f(Point3... a) 

Source Link

Usage

From source file:de.vion.eyetracking.cameracalib.calibration.opencv.CameraCalibrator.java

private double computeReprojectionErrors(List<Mat> objectPoints, List<Mat> rvecs, List<Mat> tvecs,
        Mat perViewErrors) {//w w  w.  j a v  a 2  s. c  om
    MatOfPoint2f cornersProjected = new MatOfPoint2f();
    double totalError = 0;
    double error;
    float viewErrors[] = new float[objectPoints.size()];

    MatOfDouble distortionCoefficients = new MatOfDouble(this.mDistortionCoefficients);
    int totalPoints = 0;
    for (int i = 0; i < objectPoints.size(); i++) {
        MatOfPoint3f points = new MatOfPoint3f(objectPoints.get(i));
        Calib3d.projectPoints(points, rvecs.get(i), tvecs.get(i), this.mCameraMatrix, distortionCoefficients,
                cornersProjected);
        error = Core.norm(this.mCornersBuffer.get(i), cornersProjected, Core.NORM_L2);

        int n = objectPoints.get(i).rows();
        viewErrors[i] = (float) Math.sqrt(error * error / n);
        totalError += error * error;
        totalPoints += n;
    }
    perViewErrors.create(objectPoints.size(), 1, CvType.CV_32FC1);
    perViewErrors.put(0, 0, viewErrors);

    return Math.sqrt(totalError / totalPoints);
}

From source file:org.usfirst.frc.team2084.CMonster2016.vision.CameraCalibration.java

License:Open Source License

/**
 * Calculate the corner positions of the board in world units.
 * /*from   ww  w.j  a  v a2s. c o  m*/
 * @return the calculated corners
 */
private MatOfPoint3f calcBoardCornerPositions() {
    Point3[] cornersArr = new Point3[(int) boardSize.area()];

    for (int i = 0; i < boardSize.height; ++i) {
        for (int j = 0; j < boardSize.width; ++j) {
            cornersArr[(int) ((i * boardSize.width) + j)] = new Point3(j * squareSize, i * squareSize, 0);
        }
    }
    MatOfPoint3f corners = new MatOfPoint3f(cornersArr);
    System.out.println(corners);
    return corners;
}