use of org.fagu.fmv.mymedia.classify.image.ReduceImageConverter 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.classify.image.ReduceImageConverter in project fmv by f-agu.
the class DefaultClassifierProvider method getConverter.
/**
* @see org.fagu.fmv.mymedia.classify.ClassifierProvider#getConverter(java.lang.Class)
*/
@SuppressWarnings("unchecked")
@Override
public <M extends Media> List<Converter<M>> getConverter(Class<? extends M> mediaCls, File destFolder) {
List<Converter<M>> list = new ArrayList<>();
list.add((Converter<M>) new MoveConverter(destFolder));
if (mediaCls == Image.class) {
list.add((Converter<M>) new ReduceImageConverter(destFolder));
} else if (mediaCls == Movie.class) {
list.add((Converter<M>) new MovieScriptConverter(destFolder));
}
return list;
}
Aggregations