Skip to content

Commit

Permalink
Make sure last received frame is passed on after some delay
Browse files Browse the repository at this point in the history
The needle matching might work on outdated frames if the last changes
where below the threshold. Implement a leaky bucket scheme for the
threshold so all frames but exact repetitions are candidates for updates.

For the video, the error might even have had accumulated, e.g. by a series
of frames with a similarity more than 50.

Fix for poo#19302

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
  • Loading branch information
StefanBruens committed May 26, 2017
1 parent afaaab4 commit a76ed48
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions backend/baseclass.pm
Expand Up @@ -52,11 +52,13 @@ __PACKAGE__->mk_accessors(
sub new {
my $class = shift;
my $self = bless({class => $class}, $class);
$self->{started} = 0;
$self->{serialfile} = "serial0";
$self->{serial_offset} = 0;
$self->{video_frame_data} = [];
$self->{video_frame_number} = 0;
$self->{started} = 0;
$self->{serialfile} = "serial0";
$self->{serial_offset} = 0;
$self->{video_frame_data} = [];
$self->{video_frame_number} = 0;
$self->{min_image_similarity} = 10000;
$self->{min_video_similarity} = 10000;
return $self;
}

Expand Down Expand Up @@ -367,22 +369,29 @@ sub enqueue_screenshot {
$sim = $lastscreenshot->similarity($image) if $lastscreenshot;
$watch->lap("similarity");

$self->{min_image_similarity} -= 1;
$self->{min_image_similarity} = $sim if $sim < $self->{min_image_similarity};
$self->{min_video_similarity} -= 1;
$self->{min_video_similarity} = $sim if $sim < $self->{min_video_similarity};

# we have two different similarity levels - one (slightly higher value, based
# t/data/user-settings-*) to determine if it's worth it to recheck needles
# and one (slightly lower as less significant) determining if we write the frame
# into the video
if ($sim <= 54) {
if ($self->{min_image_similarity} <= 54) {
$self->last_image($image);
$self->{min_image_similarity} = 10000;
}

if ($sim > 50) { # we ignore smaller differences
if ($self->{min_video_similarity} > 50) { # we ignore smaller differences
push(@{$self->{video_frame_data}}, "R\n");
}
else {
my $imgdata = $image->ppm_data;
$watch->lap("convert ppm data");
push(@{$self->{video_frame_data}}, 'E ' . length($imgdata) . "\n");
push(@{$self->{video_frame_data}}, $imgdata);
$self->{min_video_similarity} = 10000;
}
$self->{select}->add($self->{encoder_pipe});
$self->{video_frame_number} += 1;
Expand Down

0 comments on commit a76ed48

Please sign in to comment.