#!/usr/bin/perl -w
use warnings;
use strict;
use File::Basename;
use File::Find;
use File::Path qw(make_path);
use Image::ExifTool qw(:Public);
use POSIX qw(strftime);
use Time::Local;
my $exif = new Image::ExifTool;
my %stat;
unlink("gnuplot/total.data");
sub get_exif
{
my $file = $_[0];
my @params = @{$_[1]};
my $info = $exif->ImageInfo($file, @params);
my %value;
foreach my $p (@params)
{
if(exists $info->{$p})
{
$value{$p} = $info->{$p};
}
else
{
$value{$p} = 0;
}
}
return %value;
}
sub focus_stat
{
/\.jpe?g$/i || return;
print $File::Find::name."\n";
my $img = $File::Find::name;
my %info = get_exif($img, [
'Model',
'Lens',
'FocalLength',
'ShortFocal',
'LongFocal',
'FocalLength35efl',
'ScaleFactor35efl'
]);
next if(not $info{'FocalLength'});
next if(not $info{'ShortFocal'});
next if(not $info{'LongFocal'});
my $lens = $info{'Lens'};
$stat{$lens}{'sfocal'} = $info{'ShortFocal'};
$stat{$lens}{'model'} = $info{'Model'};
$stat{$lens}{'lfocal'} = $info{'LongFocal'};
$stat{$lens}{'crop'} = $info{'ScaleFactor35efl'};
push(@{$stat{$lens}{'data'}}, $info{'FocalLength'});
}
find(\&focus_stat, "/home/family/Our");
foreach my $lens (keys %stat)
{
print "lens = $lens\n";
open FH, ">gnuplot/$lens.gnuplot";
print FH "model = ".$stat{$lens}{'model'}."\n";
print FH "sfocal = ".$stat{$lens}{'sfocal'}."\n";
print FH "lfocal = ".$stat{$lens}{'lfocal'}."\n";
print FH "crop = ".$stat{$lens}{'crop'}."\n";
close FH;
open FH, ">gnuplot/$lens.data";
open FHT, ">>gnuplot/total.data";
foreach my $focal (@{$stat{$lens}{'data'}})
{
$focal =~ s/\s+mm$//;
my $efl = $focal * $stat{$lens}{'crop'};
print FH "$efl\n";
print FHT "$efl\n";
}
close FH;
close FHT;
}
set terminal pngcairo enhanced font "Tahoma,8" size 600,2000
set output 'total.png'
set multiplot layout 11,1 title 'Встребованность фокусных расстояний'
bin(x,width) = width*int(x/width+0.5)
round(x) = bin(x/1.6, 10/3.)
set xrange [0:260]
set xtics 10
set style fill transparent solid 0.6
set boxwidth 10./3
set xlabel "Приведённое к crop 1,6 фокусное расстояние, мм"
set ylabel "Количество снимков"
set title 'Все объективы:' font "Tahoma, 14"
plot "total.data" u (round($1)):(1.) smooth frequency w boxes lc rgb "#808080" t 'Все объективы'
set title 'Canon G7:'
plot "7.4 - 44.4 mm.data" u (round($1)):(1.) smooth frequency w boxes lc rgb "#000080" t '7.4-44.4 x 4.6 (21-128 x 1.6)'
set title 'Canon A80:'
plot "7.8 - 23.4 mm.data" u (round($1)):(1.) smooth frequency w boxes lc rgb "#800080" t '7.8-23.4 x 4.8 (23-70 x 1.6)'
set title 'Canon 1000D:'
plot "18.0 - 200.0 mm.data" u (round($1)):(1.) smooth frequency w boxes lc rgb "#808000" t 'Canon 18-200 IS x 1.6'
set title 'Canon 20D, Canon 550D:'
plot "55.0 - 250.0 mm.data" u (round($1)):(1.) smooth frequency w boxes lc rgb "#008000" t 'Canon 55-250 IS x 1.6'
set title 'Canon 550D:'
plot "50.0 mm.data" u (round($1)):(1.) smooth frequency w boxes lc rgb "#80f080" t 'Canon 50/1,8 x 1.6'
set title 'Canon A40:'
plot "5.4 - 16.2 mm.data" u (round($1)):(1.) smooth frequency w boxes lc rgb "#800000" t '5.4-16.2 x 5.6 (19-57 x 1.6)'
set title 'Canon 550D:'
plot "18.0 - 55.0 mm.data" u (round($1)):(1.) smooth frequency w boxes lc rgb "#40f080" t 'Canon 18-55 IS x 1.6'
set title 'Canon IXUS 110 IS:'
plot "5.0 - 20.0 mm.data" u (round($1)):(1.) smooth frequency w boxes lc rgb "#ff80c0" t '5.0-20.0 x 5.5 (17-69 x 1.6)'
set title 'Canon 10D:'
plot "24.0 - 105.0 mm.data" u (round($1)):(1.) smooth frequency w boxes lc rgb "#404000" t '24-105 x 1.6'
set title 'Canon IXUS 60:'
plot "5.8 - 17.4 mm.data" u (round($1)):(1.) smooth frequency w boxes lc rgb "#804040" t '5.8-17.4 x 5.9 (21-64 x 1.6)'