| 1 | package Image::Compare::THRESHOLD_COUNT; | ||
| 2 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use base qw/Image::Compare::THRESHOLD/; | ||
| 7 | |||
| 8 | sub setup { | ||
| 9 | my $self = shift; | ||
| 10 | $self->{count} = 0; | ||
| 11 | } | ||
| 12 | |||
| 13 | sub accumulate { | ||
| 14 | my $self = shift; | ||
| 15 | # The superclass returns 0 if it's over the threshold and undef otherwise. | ||
| 16 | # Not really optimal return values, but we're kind of cheating by looking | ||
| 17 | # at it in this context, so hey. | ||
| 18 | if (defined($self->SUPER::accumulate(@_))) { | ||
| 19 | $self->{count}++; | ||
| 20 | } | ||
| 21 | # Always continue. | ||
| 22 | return undef; | ||
| 23 | } | ||
| 24 | |||
| 25 | sub get_result { | ||
| 26 | my $self = shift; | ||
| 27 | return $self->{count} || 0; | ||
| 28 | } | ||
| 29 | |||
| 30 | 1; | ||
| 31 | |||
| 32 | __END__ |