Example usage for org.opencv.core Mat ones

List of usage examples for org.opencv.core Mat ones

Introduction

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

Prototype

public static Mat ones(Size size, int type) 

Source Link

Usage

From source file:com.sikulix.core.Finder.java

License:Open Source License

private Mat doFindMatch(Element target, Mat base, Mat probe) {
    if (SX.isNull(probe)) {
        probe = target.getContent();//from  ww w  . j  a v a  2s .  c  o  m
    }
    Mat result = new Mat();
    Mat plainBase = base;
    Mat plainProbe = probe;
    if (!target.isPlainColor()) {
        Imgproc.matchTemplate(base, probe, result, Imgproc.TM_CCOEFF_NORMED);
    } else {
        if (target.isBlack()) {
            Core.bitwise_not(base, plainBase);
            Core.bitwise_not(probe, plainProbe);
        }
        Imgproc.matchTemplate(plainBase, plainProbe, result, Imgproc.TM_SQDIFF_NORMED);
        Core.subtract(Mat.ones(result.size(), CvType.CV_32F), result, result);
    }
    return result;
}

From source file:org.sikuli.script.Finder.java

License:MIT License

private Mat doFindMatch(Probe probe, Mat base, Mat target) {
    Mat res = new Mat();
    Mat bi = new Mat();
    Mat pi = new Mat();
    if (!probe.img.isPlainColor()) {
        Imgproc.matchTemplate(base, target, res, Imgproc.TM_CCOEFF_NORMED);
    } else {// ww w . j a v  a 2 s . c o m
        if (probe.img.isBlack()) {
            Core.bitwise_not(base, bi);
            Core.bitwise_not(target, pi);
        } else {
            bi = base;
            pi = target;
        }
        Imgproc.matchTemplate(bi, pi, res, Imgproc.TM_SQDIFF_NORMED);
        Core.subtract(Mat.ones(res.size(), CvType.CV_32F), res, res);
    }
    return res;
}

From source file:org.sikuli.script.ImageFind.java

License:MIT License

private Core.MinMaxLocResult doFindMatch(Mat base, Mat probe) {
    Mat res = new Mat();
    Mat bi = new Mat();
    Mat pi = new Mat();
    if (!isPlainColor) {
        Imgproc.matchTemplate(base, probe, res, Imgproc.TM_CCOEFF_NORMED);
    } else {/*from w  ww .jav  a  2  s  .  c  om*/
        if (isBlack) {
            Core.bitwise_not(base, bi);
            Core.bitwise_not(probe, pi);
        } else {
            bi = base;
            pi = probe;
        }
        Imgproc.matchTemplate(bi, pi, res, Imgproc.TM_SQDIFF_NORMED);
        Core.subtract(Mat.ones(res.size(), CvType.CV_32F), res, res);
    }
    return Core.minMaxLoc(res);
}