Do not calculate segmentation again if the previous one is not finished
Whenever a segmentation is calculated it is used to draw the input
stream to the output canvas with the background blurred. The
segmentation calculation was triggered at regular intervals, but it was
not taken into account whether a previous segmentation was still being
calculated. Now a new segmentation is calculated only if the previous
one finished already.
This prevents running outdated segmentations and thus should reduce the
load on low end devices in which calculating the segmentation for a
frame takes longer than the time elapsed between frames.
Besides that, if the input stream was changed the previous segmentation
could be processed when the new one had not finished loading yet, which
could led to visual glitches. This is also implicitly fixed by this
change, as the previous segmentation will be discarded if it does not
match the expected frame id.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Loading
Please register or sign in to comment