From 39c805f23ead48cccf390eaf0394732546374e24 Mon Sep 17 00:00:00 2001 From: tobias Date: Fri, 27 Jun 2025 14:57:59 +0200 Subject: [PATCH] Finish 2.1.1 exercise 1 --- CV-App/algorithms/invis_cloak.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/CV-App/algorithms/invis_cloak.py b/CV-App/algorithms/invis_cloak.py index a7ecb25..7137d12 100644 --- a/CV-App/algorithms/invis_cloak.py +++ b/CV-App/algorithms/invis_cloak.py @@ -10,7 +10,12 @@ class InvisCloak (Algorithm): """ init function """ def __init__(self): - pass + # Number of buffered images + self.n = 5 + + # Picture buffer + self.picture_buffer = [] + """ Processes the input image""" def process(self, img): @@ -64,9 +69,17 @@ class InvisCloak (Algorithm): Hier steht Ihr Code zu Aufgabe 2.1.1 (Rauschunterdrückung) - Implementierung Mittelwertbildung über N Frames """ + self.picture_buffer.append(img) + if len(self.picture_buffer) < self.n: + # If number of buffered images < defined buffer size n, return current image + return img + elif len(self.picture_buffer) > self.n: + # If number of buffered images > defined buffer size n, remove oldest image + self.picture_buffer.pop(0) - return img + # Reduce noise, return result image + return np.mean(self.picture_buffer, axis=0).astype(np.uint8) def _212_HistogrammSpreizung(self, img): """