diff --git a/Layer.py b/Layer.py index 20eaffc..bdd809f 100644 --- a/Layer.py +++ b/Layer.py @@ -1,17 +1,18 @@ class Layer: #data = [(contour, (x,y,w,h)),] - data = [] + startFrame = None lastFrame = None - backgroundImage = [] def __init__(self, startFrame, data): self.startFrame = startFrame self.lastFrame = startFrame + self.data = [] self.data.append(data) print("Layer constructed") def add(self, frameNumber, data): - self.lastFrame = frameNumber - self.data.append(data) + if not (self.startFrame + len(self.data) - frameNumber < 0): + self.lastFrame = frameNumber + self.data.append(data) diff --git a/LayerFactory.py b/LayerFactory.py index 2df91c1..50992a9 100644 --- a/LayerFactory.py +++ b/LayerFactory.py @@ -34,13 +34,13 @@ class LayerFactory: i = 0 for i in range(0, len(layers)): layer = layers[i] - + if len(layer.data[-1][1]) != 4: # should never be called, hints at problem in ContourExtractor print("LayerFactory: Layer knew no bounds") continue - if frameNumber - layer.lastFrame <= 5: + if frameNumber - layer.lastFrame <= 1: (x2,y2,w2,h2) = layer.data[-1][1] if self.contoursOverlay((x-tol,y+h+tol), (x+w+tol,y-tol), (x2,y2+h2), (x2+w2,y2)): foundLayer = True diff --git a/__pycache__/Layer.cpython-37.pyc b/__pycache__/Layer.cpython-37.pyc index ca0d5e4..62c7a0f 100644 Binary files a/__pycache__/Layer.cpython-37.pyc and b/__pycache__/Layer.cpython-37.pyc differ diff --git a/__pycache__/LayerFactory.cpython-37.pyc b/__pycache__/LayerFactory.cpython-37.pyc index 80ca3a9..7b77310 100644 Binary files a/__pycache__/LayerFactory.cpython-37.pyc and b/__pycache__/LayerFactory.cpython-37.pyc differ diff --git a/short.mp4 b/short.mp4 index 33764e0..cd9e5d1 100644 Binary files a/short.mp4 and b/short.mp4 differ