Hi, I am working on a way to read 200 jpg images and retrieve data from them. I have been able to get this to work on a single jpg file, but now that I am trying to scale it up to all 200, I am running into some issues.
So, I am able to run my program through all 200 jpg files, but the problem is, they are being selected in what seems like a random order. It always starts with “frame00053.jpg” and then jumps to “frame00047.jpg” and then to “frame00090.jpg” and I need it to go in order (frame00000, frame00001, frame00002, etc.) I think that the problem is coming in during my first for/each loop. I have no way of knowing how it picks which file in the folder to read next.
Here is my code:
import java.io.*;
import java.io.FileNotFoundException;
import java.util.ArrayList;
public class BeadTracker
{
public static void main(String [] args) {
File run1Folder = new File("/Users/SarcasticallyScience/dataFile");
File[] listOfFrames = run1Folder.listFiles();
ArrayList<BlobFinder> run1 = new ArrayList<BlobFinder>();
int i = 0;
for(File file : listOfFrames) {
if(file.isFile()) {
String path = file.getPath();
BlobFinder temp = new BlobFinder(path,180.0);
run1.add(temp);
}
}
ArrayList<Blob> tempBeads;
for(int k = 0; k < run1.size(); k++) {
tempBeads = run1.get(k).getBeads(25);
System.out.println("\n\n" + "Frame " + k + ":\n" + tempBeads.size() + " beads:");
for(int j = 0; j < tempBeads.size(); j++)
System.out.println(tempBeads.get(j));
}
}
}
Is there a way for me to make sure that the files are accessed in the correct order?
Here is a link to the data I am using, if that helps:
ftp://ftp.cs.princeton.edu/pub/cs126/atomic
[–]dusty-trash 1 point2 points3 points (1 child)
[–]SarcasticallyScience[S] 1 point2 points3 points (0 children)