my $Statistics;
my $PMap;
-
+my $hitcount;
###############################################################################
## Configuration ##############################################################
my $opt_frameinfo = 0;
my $opt_picpath = "./";
my $totalevents = 1E9;
+my $opt_movie = 0;
my $mode = "";
GetOptions ('h|help' => \$opt_help,
'v|verb' => \$opt_verb,
'i|info' => \$opt_frameinfo,
'd|debug' => \$opt_debug,
- 'p|picpath=s' => \$opt_picpath,
+ 'p|picpath=s' => \$opt_picpath,
+ 'm|movie=i' => \$opt_movie,
'e|events=i' => \$totalevents);
printf("[-v|--verb] Dump hld file content\n");
printf("[-i|--info] Show frame information\n");
printf("[-d|--debug] More debugging output\n");
+ printf("[-m|--movie] Make a slideshow of frames\n");
printf("[-p|--picpath] Set where to write plots\n");
printf("\n");
exit;
#----------> User function <---------
&analyzeData($evtHeader_aref, $subEvtHeader_aref, $data_aref);
}
+ if($opt_movie) {
+ WriteResults($evtHeader_aref->[3]);
+ $PMap = {};
+ $Statistics = {};
+ $hitcount = {};
+ last if $opt_movie < $evtHeader_aref->[3];
+ }
}
-WriteResults();
+WriteResults() unless $opt_movie;
$fh->close();
$ovf += ($d >> 15) & 1;
$line = ($d >> 4) & 0x7FF;
$statecnt = $d & 0xF;
+ $hitcount->{$SensorId}++;
}
else {
$pixels = ($d & 0x3);
$column = ($d >> 2) & 0x7FF;
printf("\t$line, $column x %d\n",$pixels+1) if $opt_frameinfo;
-
+ $hitcount->{$SensorId}++;
$matrix->[$line]->[$column]++;
if ($pixels > 0) {
$matrix->[$line]->[$column+1]++;
}
}
+my $fg = undef;
sub WriteResults {
-
+ my ($num ) = @_;
+ $num = "_".$num if defined $num;
+ $num = "" unless defined $num;
foreach my $id (keys $Statistics) {
#No frames? No plot!
if(!defined $Statistics->{$id}->{Valid}) {next;}
- my $fn = "gnuplot";
- $fh = new FileHandle ("|$fn") or die "error: no gnuplot";
- $fh->autoflush(1);
-
- print $fh "set terminal png size 800,400 font \",9\";\n";
- print $fh strftime("set label 100 \"%H:%M:%S\" at screen 0.98,0.02 right tc rgb \"#000044\" font \"monospace,8\"\n", localtime());
- print $fh "set palette model RGB;\n";
- print $fh "set xrange [0:1152];\n";
- print $fh "set yrange [0:576];\n";
- print $fh "set cbrange [0:5000];\n";
- print $fh "set palette defined ( 0 'white', 1 'red', 5 'black', 10 'blue', 5000 'green');\n";
- my $s = sprintf("%04x",$id);
- print $fh "set output '$opt_picpath/image_recalibrated_$s.png';\n";
- print $fh "plot '-' matrix with image\n";
+ if(!defined $fg) {
+ $fg = new FileHandle ("|gnuplot") or die "error: no gnuplot";
+ $fg->autoflush(1);
+ print $fg "set terminal png size 800,400 font \",9\";\n";
+ print $fg "set palette model RGB;\n";
+ print $fg "set xrange [0:1152];\n";
+ print $fg "set yrange [0:576];\n";
+ print $fg "set cbrange [0:5000];\n";
+ print $fg "set palette defined ( 0 'white', 1 'red', 5 'black', 10 'blue', 5000 'green');\n";
+ my $s = sprintf("%04x",$id);
+
+ print $fg strftime("set label 100 \"%H:%M:%S\" at screen 0.98,0.02 right tc rgb \"#000044\" font \"monospace,8\"\n", localtime());
+ print $fg "set label 101 \"".$hitcount->{$id}." States\" at screen 0.02,0.02 left tc rgb \"#000044\" font \"monospace,8\"\n" ;
+ print $fg "set output '$opt_picpath/image_recalibrated_$s$num.png';\n";
+ print $fg "plot '-' matrix with image\n";
+ }
+ else {
+ my $s = sprintf("%04x",$id);
+ print $fg strftime("set label 100 \"%H:%M:%S\" at screen 0.98,0.02 right tc rgb \"#000044\" font \"monospace,8\"\n", localtime());
+ print $fg "set label 101 \"".$hitcount->{$id}." States\" at screen 0.02,0.02 left tc rgb \"#000044\" font \"monospace,8\"\n" ;
+ print $fg "set output '$opt_picpath/image_recalibrated_$s$num.png';\n";
+ print $fg "replot\n";
+
+ }
+
my @matrix;
@matrix = map {$_ || 0 } @{$map};
#Join lines
my $l = join(" ",@matrix);
- print $fh $l."\n";
+ print $fg $l."\n";
}
- print $fh "e\nexit\n";
- $fh->close();
+ print $fg "e\n\n";
+ $fg->close();
+ $fg = undef;
}