diff options
| author | jules@lens <julescarbon@gmail.com> | 2018-05-18 09:04:04 +0200 |
|---|---|---|
| committer | jules@lens <julescarbon@gmail.com> | 2018-05-18 09:04:04 +0200 |
| commit | e617254facb9d5e0246a1ac35721ec245230783f (patch) | |
| tree | e974c14397b88d6808c761a5ed4b17b900c76166 /scripts/builders/flat-multi-dataset.pl | |
| parent | 9f1bf9b305681492197f4f11b88f36c37ef4ba05 (diff) | |
new builder scripts
Diffstat (limited to 'scripts/builders/flat-multi-dataset.pl')
| -rwxr-xr-x | scripts/builders/flat-multi-dataset.pl | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/scripts/builders/flat-multi-dataset.pl b/scripts/builders/flat-multi-dataset.pl new file mode 100755 index 0000000..a111983 --- /dev/null +++ b/scripts/builders/flat-multi-dataset.pl @@ -0,0 +1,75 @@ +#!/usr/bin/perl + +use strict; + +# Processing script for Adversarial Video Generation library +# Images should all be 320x or similar + +our $images_dir = "/home/lens/Desktop/woods_gray/"; +our $thumbs_dir = "/home/lens/Desktop/thumbs/kaulsdorf_gray/"; + +mkdir($thumbs_dir); +mkdir($thumbs_dir . "Train/"); +mkdir($thumbs_dir . "Test/"); + +our $frames_per_dir = 256; +our $test_split = 5; # 1/N videos will be for the test split + +our $dircount = 0; + +sub parse_dir ($) { + our ($im_dir) = @_; + our @files = (); + + print $im_dir . "\n"; + + opendir DIR, $im_dir; + while (readdir DIR) { + next if /^\./; + push(@files, $_); + } + closedir DIR; + + our @images = sort @files; + + my $count = scalar(@images); + + my $i; + my $j; + my $dirid = -2; + my $nextid; + my $dir; + for ($i = 0; $i < $count; $i++) { + $nextid = int($i / $frames_per_dir) + $dircount; + if ($nextid != $dirid) { + $dirid = $nextid; + if (($dirid % $test_split) != ($test_split-1)) { + $dir = $thumbs_dir . "Train/video" . $dirid . "/"; + } else { + $dir = $thumbs_dir . "Test/video" . $dirid . "/"; + } + print $dir . "\n"; + mkdir($dir); + $j = 0; + } else { + $j += 1; + } + + my $src = $im_dir . $images[$i]; + my $dst = $dir . sprintf("frame%03d.png", $j); + system("cp", $src, $dst); + # print $dst . "\n"; + } + + $dircount = $nextid + 1; + print $count . " " . $dircount . "\n"; +} + +opendir D, $images_dir; +while (readdir D) { + next if /^\./; + next if ! -d $images_dir . $_; + parse_dir($images_dir . $_ . "/"); +} +closedir D; + |
