Example usage for org.opencv.core Mat submat

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

Introduction

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

Prototype

public Mat submat(Rect roi) 

Source Link

Usage

From source file:vista.frmPrincipal.java

public Mat Sub_Image(Mat image, Rect roi) {
    Mat result = image.submat(roi);
    return result;
}

From source file:xored.vpn.fixer.TokenDetector.java

public boolean run() throws IOException, InterruptedException {
    saveImage();/* w  ww  .  j  a  va 2  s  .  c  om*/
    Mat source = Highgui.imread(workspace + "original.jpg", Highgui.CV_LOAD_IMAGE_COLOR);

    Mat destination = new Mat(source.rows(), source.cols(), source.type());

    List<Mat> mats = new ArrayList<>();
    mats.add(new Mat());
    mats.add(new Mat());
    mats.add(new Mat());
    Core.split(source, mats);

    mats.get(1).convertTo(destination, -1, 2);
    imwrite(workspace + "green-ajusted.jpg", destination);

    Mat image = Highgui.imread(workspace + "green-ajusted.jpg", Imgproc.COLOR_RGB2GRAY);

    Rect rect = new Rect(176, 265, 178, 52);
    Mat imageB = threshold(image.submat(rect), 15, 2);

    int iWidth = 28;
    int iHeight = 45;
    List<Mat> matList = Arrays.asList(imageB, imageB.submat(new Rect(0, 0, iWidth, iHeight)),
            imageB.submat(new Rect(28, 2, iWidth, iHeight)), imageB.submat(new Rect(54, 2, iWidth, iHeight)),
            imageB.submat(new Rect(95, 5, iWidth, iHeight)), imageB.submat(new Rect(122, 6, iWidth, iHeight)),
            imageB.submat(new Rect(150, 7, iWidth, iHeight)));
    imwrite(temp + "1.jpg", matList.get(1));
    imwrite(temp + "2.jpg", matList.get(2));
    imwrite(temp + "3.jpg", matList.get(3));
    imwrite(temp + "4.jpg", matList.get(4));
    imwrite(temp + "5.jpg", matList.get(5));
    imwrite(temp + "6.jpg", matList.get(6));

    Mat m = addTo(source, matList);
    Core.rectangle(m, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height),
            new Scalar(0, 0, 255));

    String code = recognize();
    imwrite(workspace + "ResultsDebug/" + code + ".jpg", m);

    Main.log("Using code: " + code);
    Main.log("Using username: " + Main.username);
    Main.log("Using pin: " + Main.pin);

    String command = Main.nclauncher + " -url https://vpn.spirent.com/xored -r \"Contractor - Xored\" -u "
            + Main.username + " -p " + Main.pin + code;
    String response = Main.execCmd(command);
    Main.log(response);
    return response.indexOf("is already running") >= 0;
}