I need some help. I created a function that read a single image. Well, it's work, but I want to create something like a loop for get all images from directory and use the imread method for get pixels values. How I can do this? follow my code below.
public void cor() {
String src = ("path_to_folder");
Mat imgread;
imgread = Imgcodecs.imread(src, IMREAD_COLOR);
Mat rgbimage = null; //for conversion bgr2rgb
int lin = imgread.rows(); //get the number of rows
int col = imgread.cols(); //get the number of cols
if (imgread.empty()) {
Log.e("error", "is empty!");
} else {
rgbimage = new Mat(imgread.size(), imgread.type());
Imgproc.cvtColor(imgread, rgbimage, Imgproc.COLOR_BGR2RGB);
}
for (int i = 0; i < lin; i++) {
for (int j = 0; j < col; j++) {
double[] rgb =rgbimage.get(i, j);
pixels.add(rgb); //put data in arraylist
}
}
}