Created
July 19, 2019 19:14
-
-
Save ahmedfgad/2e25732b1e398cd2a51808d702778c6f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = {"apple", "lemon", "mango", "raspberry"}; | |
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) { | |
// Make sure we are working with a 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++; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment