use of org.fagu.fmv.mymedia.file.ImageFinder in project fmv by f-agu.
the class Images method prepare.
/**
* @param size
*/
public PreparedImages prepare(Size size) throws IOException {
final int COUNT_TOTAL = getImages().size();
File destFolder = new File(sourceFolder.getParent(), sourceFolder.getName() + "-img2mov");
if (destFolder.exists()) {
File[] listFiles = destFolder.listFiles(f -> f.getName().startsWith("img_"));
if (listFiles.length == COUNT_TOTAL) {
return new PreparedImages(Arrays.asList(listFiles));
}
}
final AtomicInteger count = new AtomicInteger();
ConverterListener<Image> converterListener = new ConverterListener<Image>() {
/**
* @see org.fagu.fmv.mymedia.classify.ConverterListener#eventPreConvert(org.fagu.fmv.media.Media,
* java.io.File)
*/
@Override
public void eventPreConvert(Image srcMedia, File destFile) {
System.out.println("Convert (" + count.incrementAndGet() + "/" + COUNT_TOTAL + "): " + srcMedia.getFile());
}
};
try (ReduceImageConverter converter = new ReduceImageConverter(destFolder)) {
converter.setSize(size);
try (Classifier<ImageFinder, Image> classifier = ClassifierFactories.imagesToMovie().create(imageFinder, destFolder)) {
return new PreparedImages(classifier.classify(converter, converterListener));
}
}
}
use of org.fagu.fmv.mymedia.file.ImageFinder in project fmv by f-agu.
the class Bootstrap method main.
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
File source = new File(args[0]);
File saveFile = new File(source, "image.save");
File destFolder = new File(source.getParentFile(), source.getName() + "-out");
Bootstrap bootstrap = new Bootstrap();
try (ImageFinder imageFinder = bootstrap.findImage(saveFile, source)) {
Organizer<ImageFinder, Image> organizer = new Organizer<>(Image.class);
organizer.organize(destFolder, imageFinder);
}
}
use of org.fagu.fmv.mymedia.file.ImageFinder in project fmv by f-agu.
the class Bootstrap method findImage.
// ---------------------------------------------------
/**
* @param saveFile
* @param srcFiles
* @return
* @throws IOException
*/
private ImageFinder findImage(File saveFile, File... srcFiles) throws IOException {
ImageFinder imagesFinder = new ImageFinder(saveFile);
// imagesFinder.addListener(new FileFinderListener<Image>() {
//
// private int count;
//
// /**
// * @see org.fagu.fmv.utils.file.FileFinderListener#eventFind(java.io.File, java.lang.Object)
// */
// @Override
// public void eventFind(File file, Image image) {
// ImageMetadatas metadatas = image.getMetadatas();
// String model = metadatas.getDeviceModel();
// String device = metadatas.getDevice();
//
// System.out.println(count + ": " + file.getName() + " : " + device + ", " + model);
// ++count;
// }
// });
FindProgress findProgress = new FindProgress() {
private TextProgressBar textProgressBar = TextProgressBar.newBar().fixWidth(40).withText("Finding images").buildForPrinting();
/**
* @see org.fagu.fmv.utils.file.FindProgress#progress(int, int)
*/
@Override
public void progress(int done, int total) {
textProgressBar.print((100 * done) / total);
}
};
imagesFinder.find(Arrays.asList(srcFiles), findProgress);
return imagesFinder;
}
use of org.fagu.fmv.mymedia.file.ImageFinder in project fmv by f-agu.
the class FindDiffTime method main.
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
ImageFinder imagesFinder = Sources.load(new File("C:\\tmp\\july\\save"));
for (FileFinder<Image>.InfosFile infosFile : imagesFinder.getAll()) {
Image image = infosFile.getMain();
File file = image.getFile();
System.out.println(file.getParentFile().getName() + "/" + file.getName() + " : " + DATE_FORMAT.format(new Date(image.getTime())));
if ("GOPR0698.JPG".equals(file.getName())) {
Calendar calendar = Calendar.getInstance();
calendar.set(2014, Calendar.JULY, 10, 15, 30, 0);
System.out.println("############### " + (image.getTime() - calendar.getTimeInMillis()));
}
}
}
Aggregations