Example usage for org.opencv.core Mat dims

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

Introduction

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

Prototype

public int dims() 

Source Link

Usage

From source file:com.oetermann.imageclassifier.DescriptorExtractorWrapper.java

License:Open Source License

public List<Mat> readImages(List<String> files, boolean grayscale) {
    List<Mat> images = new ArrayList<>();
    Mat mat;

    for (ListIterator<String> it = files.listIterator(); it.hasNext();) {
        String file = it.next();/*from www  .  ja v  a 2  s . co  m*/
        mat = Imgcodecs.imread(file);
        if (mat.dims() > 0 && mat.cols() > 0 && mat.rows() > 0) {
            if (grayscale) {
                Imgproc.cvtColor(mat, mat, Imgproc.COLOR_RGB2GRAY);
            }
            images.add(mat);
        } else {
            it.remove();
            System.out.println("Cannot read file: " + file);
        }
    }
    return images;
}