diff --git a/Application/Config.py b/Application/Config.py index a4cf15b..17ba952 100644 --- a/Application/Config.py +++ b/Application/Config.py @@ -14,7 +14,8 @@ class Config: "ttolerance": 60, "videoBufferLength": 1000, "noiseThreashold": 0.05, - "noiseSensitivity": 3/4 + "noiseSensitivity": 3/4, + "LayersPerContour": 5 } def __init__(self): diff --git a/Application/LayerFactory.py b/Application/LayerFactory.py index f8573fd..868faf5 100644 --- a/Application/LayerFactory.py +++ b/Application/LayerFactory.py @@ -101,22 +101,25 @@ class LayerFactory: bounds = data[1] (x,y,w,h) = bounds tol = self.tolerance - foundLayer = False - for i in set(range(0, len(self.layers))).difference(set(self.oldLayerIDs)): + foundLayer = 0 + + for i in range(0, len(self.layers)): + if i in self.oldLayerIDs: + continue if frameNumber - self.layers[i].lastFrame > self.ttolerance: self.oldLayerIDs.append(i) continue for bounds in self.layers[i].bounds[-1]: - if bounds is None: + if bounds is None or foundLayer >= self.config["LayersPerContour"]: break (x2,y2,w2,h2) = bounds if self.contoursOverlay((x-tol,y+h+tol), (x+w+tol,y-tol), (x2,y2+h2), (x2+w2,y2)): self.layers[i].add(frameNumber, (x,y,w,h)) - foundLayer = True - break + foundLayer += 1 + #break - if not foundLayer: + if foundLayer == 0: self.layers.append(Layer(frameNumber, (x,y,w,h), self.config)) def contoursOverlay(self, l1, r1, l2, r2): diff --git a/main.py b/main.py index c6dafd7..67f0645 100644 --- a/main.py +++ b/main.py @@ -16,7 +16,7 @@ def demo(): config = Config() - config["inputPath"] = os.path.join(os.path.dirname(__file__), "generate test footage/out.mp4") + config["inputPath"] = os.path.join(os.path.dirname(__file__), "generate test footage/3.mp4") #config["importPath"] = os.path.join(os.path.dirname(__file__), "output/short.txt") config["outputPath"] = os.path.join(os.path.dirname(__file__), "output/short.mp4") @@ -31,7 +31,7 @@ def demo(): layerFactory = LayerFactory(config) layers = layerFactory.extractLayers(contours) - layerFactory.fillLayers() + #layerFactory.fillLayers() else: layers = Importer(config).importRawData() diff --git a/output/short.txt b/output/short.txt index 733af0f..9ea973f 100644 Binary files a/output/short.txt and b/output/short.txt differ