System.out.println("orientation : "+orientation);
System.out.println("low level counting : "+counting);
int i = 0;
//creation extracteur de gaborettes
MacroGaborDescriptorCreator creator = new MacroGaborDescriptorCreator();
Detector detector = new HoneycombDetector(spacing, scaling);
creator.setDetector(detector);
creator.setOrientation(orientation);
creator.setCounting(counting);
//processing all files
String[] files = (new File(inDir)).list(new FilenameFilter(){
public boolean accept(File dir, String name) {
if(name.endsWith("lck"))
return false;
if(!name.endsWith("jpg") && !name.endsWith("JPG") && !name.endsWith("png") && !name.endsWith("PNG"))
return false;
return true;
}});
ArrayList<String> listOfImages = new ArrayList<String>();
listOfImages.addAll(Arrays.asList(files));
System.out.println(listOfImages.size()+" to do.");
while(!listOfImages.isEmpty())
{
Collections.shuffle(listOfImages);
String s = listOfImages.remove(0);
System.out.println("processing "+s);
long tim = System.currentTimeMillis();
String outFileName = s.substring(0, s.lastIndexOf("."))+".gab";
File outFile= new File(outDir+"/"+outFileName+".xgz");
if(outFile.exists())
{
System.out.println("already done.");
continue;
}
String lockFileName = s+".lck";
File lockFile = new File(lockFileName);
FileLock ifl = (new FileOutputStream(lockFile)).getChannel().tryLock();
if(ifl == null)
{
System.out.println("already in processing");
continue;
}
//extract descriptors
ArrayList<GaborDescriptor> list = creator.createDescriptors(inDir+"/"+s);
XMLWriter.writeXMLFile(outDir+"/"+outFileName, list, true);
ifl.release();
lockFile.delete();
System.out.println(s+" done ("+(System.currentTimeMillis()-tim)+")");
}
//formatting stat
double mean[] = creator.getMeanGabor();
double squareMean[] = creator.getStdGabor();
for(i = 0 ; i < mean.length; i++)
{
mean[i] /= creator.getNbProcessedDescriptors();
squareMean[i] /= creator.getNbProcessedDescriptors();
}
//printing stats
System.out.println("writing stats");
System.out.println("nb descriptors done : "+creator.getNbProcessedDescriptors());
// objOut.writeInt(creator.getNbProcessedDescriptors());
System.out.println("sum descriptor : "+Arrays.toString(mean));
// objOut.writeObject(mean);
System.out.println("sum square descriptors : "+Arrays.toString(squareMean));
// objOut.writeObject(squareMean);