Example usage for org.opencv.imgproc Imgproc remap

List of usage examples for org.opencv.imgproc Imgproc remap

Introduction

In this page you can find the example usage for org.opencv.imgproc Imgproc remap.

Prototype

public static void remap(Mat src, Mat dst, Mat map1, Mat map2, int interpolation) 

Source Link

Usage

From source file:org.openpnp.machine.reference.ReferenceCamera.java

License:Open Source License

private Mat undistort(Mat mat) {
    if (!calibration.isEnabled()) {
        return mat;
    }/*from   w w w.  j a v  a 2  s .  c o  m*/

    if (undistortionMap1 == null || undistortionMap2 == null) {
        undistortionMap1 = new Mat();
        undistortionMap2 = new Mat();
        Mat rectification = Mat.eye(3, 3, CvType.CV_32F);
        Imgproc.initUndistortRectifyMap(calibration.getCameraMatrixMat(),
                calibration.getDistortionCoefficientsMat(), rectification, calibration.getCameraMatrixMat(),
                mat.size(), CvType.CV_32FC1, undistortionMap1, undistortionMap2);
        rectification.release();
    }

    Mat dst = mat.clone();
    Imgproc.remap(mat, dst, undistortionMap1, undistortionMap2, Imgproc.INTER_LINEAR);
    mat.release();

    return dst;
}