Search in sources :

Example 1 with ImageFinder

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));
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ImageFinder(org.fagu.fmv.mymedia.file.ImageFinder) ConverterListener(org.fagu.fmv.mymedia.classify.ConverterListener) Image(org.fagu.fmv.im.Image) File(java.io.File) ReduceImageConverter(org.fagu.fmv.mymedia.classify.image.ReduceImageConverter)

Example 2 with ImageFinder

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);
    }
}
Also used : Organizer(org.fagu.fmv.mymedia.classify.Organizer) ImageFinder(org.fagu.fmv.mymedia.file.ImageFinder) Image(org.fagu.fmv.im.Image) File(java.io.File)

Example 3 with 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;
}
Also used : ImageFinder(org.fagu.fmv.mymedia.file.ImageFinder) TextProgressBar(org.fagu.fmv.textprogressbar.TextProgressBar) FindProgress(org.fagu.fmv.utils.file.FindProgress)

Example 4 with ImageFinder

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()));
        }
    }
}
Also used : ImageFinder(org.fagu.fmv.mymedia.file.ImageFinder) Calendar(java.util.Calendar) FileFinder(org.fagu.fmv.utils.file.FileFinder) Image(org.fagu.fmv.im.Image) File(java.io.File) Date(java.util.Date)

Aggregations

ImageFinder (org.fagu.fmv.mymedia.file.ImageFinder)4 File (java.io.File)3 Image (org.fagu.fmv.im.Image)3 Calendar (java.util.Calendar)1 Date (java.util.Date)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ConverterListener (org.fagu.fmv.mymedia.classify.ConverterListener)1 Organizer (org.fagu.fmv.mymedia.classify.Organizer)1 ReduceImageConverter (org.fagu.fmv.mymedia.classify.image.ReduceImageConverter)1 TextProgressBar (org.fagu.fmv.textprogressbar.TextProgressBar)1 FileFinder (org.fagu.fmv.utils.file.FileFinder)1 FindProgress (org.fagu.fmv.utils.file.FindProgress)1