Example usage for org.opencv.core Rect toString

List of usage examples for org.opencv.core Rect toString

Introduction

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

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:org.it.tdt.edu.vn.platedetection.process.LicensePlateDetection.java

License:Open Source License

public void executePreprocessor() {
    OriginalImage originalImage = new OriginalImage(imgUrl);
    BufferedImage bufferedImage = originalImage.getImageFromResourcesDirectory();
    OriginalMat originalMat = new OriginalMat(bufferedImage);

    Mat mat = originalMat.createGrayImage();
    showImageResult(mat, "nh gc");
    long blackCount = 0;
    long whiteCount = 0;

    for (int i = 0; i < mat.rows(); i++) {
        for (int j = 0; j < mat.cols(); j++) {
            double temp[] = mat.get(i, j);
            if (temp[0] > 230)
                whiteCount++;//w ww .j a v a  2 s. c o  m
            else if (temp[0] < 35)
                blackCount++;
        }
    }
    int index = 0;
    for (int i = 0; i < mat.rows(); i += 16) {
        for (int j = 0; j < mat.cols(); j += 8) {
            Rect rect = new Rect(new Point(i, j), new Size(8, 16));
            index++;
            System.out.println(rect.toString());
        }
    }
    System.out.println(index);
    ThresholdMat thresholdMat = new ThresholdMat(mat, 0, 255, Imgproc.THRESH_OTSU);
    Mat mat1 = thresholdMat.createMatResult();
    if (blackCount > whiteCount) {
        showImageResult(mat1, "nh ly  ly ngng");

        CloseMat openMat = new CloseMat(mat1, Imgproc.MORPH_RECT, 5, 5, 1);
        Mat mat2 = openMat.createMatResult();
        showImageResult(mat2, "Thut ton open");
    } else {

    }
}