Commit 0ba37063 authored by Gunasinghe M.D.'s avatar Gunasinghe M.D.

Classification - read images

parent a922e4a0
package opencvapp;
import java.io.File;
import org.opencv.core.Core;
public class TrainANN {
public static void main(String [] args){
String currentDirectory = System.getProperty("user.dir");
System.load(currentDirectory + "\\OpenCVDLL\\x64\\" + Core.NATIVE_LIBRARY_NAME + ".dll");
String [] classesNames = {"vert_line","hor_line","circle", "rectangle", "triangle", "rhombus"};
for(int classIdx=0; classIdx<classesNames.length; classIdx++){
String currClassName = classesNames[classIdx];
String currClassDir = currentDirectory + "\\Dataset\\Train\\" + currClassName + "\\";
System.out.println("Current Class Directory : " + currClassDir);
File folder = new File(currClassDir);
File[] listOfFiles = folder.listFiles();
// Counter for the number of image being processed within the class.
int imgCount = 0;
for (File listOfFile : listOfFiles) {
// Check whether the file and its extension is JPG.
if (listOfFile.isFile() && (currClassDir + listOfFile.getName()).endsWith(".jpg")) {
System.out.println("\nClass Index " + classIdx + "(" + currClassName + ")" + ", Image Index " + imgCount + "(" + listOfFile.getName() + ")");
String currImgPath = currClassDir + listOfFile.getName();
System.out.println(currImgPath);
imgCount++;
}
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment