Example usage for org.opencv.core Core transform

List of usage examples for org.opencv.core Core transform

Introduction

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

Prototype

public static void transform(Mat src, Mat dst, Mat m) 

Source Link

Usage

From source file:arlocros.Utils.java

License:Apache License

static public Mat tresholdContrastBlackWhite(Mat srcImage, int filterBlockSize, double subtractedConstant,
        boolean invertBlackWhiteColor) {

    final Mat transformMat = new Mat(1, 3, CvType.CV_32F);
    final int row = 0;
    final int col = 0;
    transformMat.put(row, col, 0.33, 0.33, 0.34);

    final Mat grayImage = new Mat(srcImage.height(), srcImage.width(), CvType.CV_8UC1);
    Core.transform(srcImage, grayImage, transformMat);

    Mat thresholdedImage = new Mat(grayImage.height(), grayImage.width(), CvType.CV_8UC1);
    Imgproc.adaptiveThreshold(grayImage, thresholdedImage, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C,
            Imgproc.THRESH_BINARY, filterBlockSize, subtractedConstant);
    grayImage.release();// w  ww  . j av a 2s  .c o  m

    if (invertBlackWhiteColor) {
        final Mat invertedImage = new Mat(thresholdedImage.height(), thresholdedImage.width(), CvType.CV_8UC1);
        Core.bitwise_not(thresholdedImage, invertedImage);
        thresholdedImage.release();
        thresholdedImage = invertedImage;
    }

    final Mat coloredImage = new Mat(thresholdedImage.height(), thresholdedImage.width(), CvType.CV_8UC3);
    Imgproc.cvtColor(thresholdedImage, coloredImage, Imgproc.COLOR_GRAY2RGB);
    thresholdedImage.release();
    return coloredImage;
}

From source file:com.shootoff.camera.autocalibration.AutoCalibrationManager.java

License:Open Source License

private Mat warpCorners(MatOfPoint2f imageCorners) {
    Mat mat = null;//from  w ww.j  a  v  a  2  s .c  om

    if (warpInitialized) {
        mat = new Mat();
        Core.transform(imageCorners, mat, perspMat);
    } else {
        logger.warn("warpCorners called when warpInitialized is false - {} {} - {}", perspMat, boundingBox,
                isCalibrated);
    }

    return mat;
}