num,ber of layer correct, too many frames per layer
This commit is contained in:
parent
efa299a9f5
commit
6fb5d6714e
6
Layer.py
6
Layer.py
|
|
@ -1,8 +1,8 @@
|
||||||
class Layer:
|
class Layer:
|
||||||
#data = [(contour, (x,y,w,h)),]
|
#data = [(contour, (x,y,w,h)),]
|
||||||
data = []
|
data = []
|
||||||
startFrame = 0
|
startFrame = None
|
||||||
lastFrame = 0
|
lastFrame = None
|
||||||
backgroundImage = []
|
backgroundImage = []
|
||||||
|
|
||||||
def __init__(self, startFrame, data):
|
def __init__(self, startFrame, data):
|
||||||
|
|
@ -10,7 +10,7 @@ class Layer:
|
||||||
self.lastFrame = startFrame
|
self.lastFrame = startFrame
|
||||||
self.data.append(data)
|
self.data.append(data)
|
||||||
|
|
||||||
#print("Layer constructed")
|
print("Layer constructed")
|
||||||
|
|
||||||
def add(self, frameNumber, data):
|
def add(self, frameNumber, data):
|
||||||
self.lastFrame = frameNumber
|
self.lastFrame = frameNumber
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ from Layer import Layer
|
||||||
class LayerFactory:
|
class LayerFactory:
|
||||||
data = {}
|
data = {}
|
||||||
layers = []
|
layers = []
|
||||||
|
tolerance = 10
|
||||||
def __init__(self, data=None):
|
def __init__(self, data=None):
|
||||||
print("LayerFactory constructed")
|
print("LayerFactory constructed")
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
@ -10,6 +11,8 @@ class LayerFactory:
|
||||||
self.extractLayers(data)
|
self.extractLayers(data)
|
||||||
|
|
||||||
def extractLayers(self, data = None):
|
def extractLayers(self, data = None):
|
||||||
|
tol = self.tolerance
|
||||||
|
|
||||||
if self.data is None:
|
if self.data is None:
|
||||||
if data is None:
|
if data is None:
|
||||||
print("LayerFactory data was none")
|
print("LayerFactory data was none")
|
||||||
|
|
@ -27,18 +30,24 @@ class LayerFactory:
|
||||||
# inserts all the fucking contours as layers?
|
# inserts all the fucking contours as layers?
|
||||||
for frameNumber, contours in data.items():
|
for frameNumber, contours in data.items():
|
||||||
for contour, (x,y,w,h) in contours:
|
for contour, (x,y,w,h) in contours:
|
||||||
for layer in layers:
|
foundLayer = False
|
||||||
|
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 <= 5:
|
||||||
if len(layer.data[-1][1]) != 4:
|
|
||||||
print("LayerFactory: Layer knew no bounds")
|
|
||||||
continue
|
|
||||||
|
|
||||||
(x2,y2,w2,h2) = layer.data[-1][1]
|
(x2,y2,w2,h2) = layer.data[-1][1]
|
||||||
tol = 10
|
|
||||||
if self.contoursOverlay((x-tol,y+h+tol), (x+w+tol,y-tol), (x2,y2+h2), (x2+w2,y2)):
|
if self.contoursOverlay((x-tol,y+h+tol), (x+w+tol,y-tol), (x2,y2+h2), (x2+w2,y2)):
|
||||||
|
foundLayer = True
|
||||||
layer.add(frameNumber, (contour, (x,y,w,h)))
|
layer.add(frameNumber, (contour, (x,y,w,h)))
|
||||||
break
|
|
||||||
|
layers[i] = layer
|
||||||
|
if not foundLayer:
|
||||||
layers.append(Layer(frameNumber, (contour, (x,y,w,h))))
|
layers.append(Layer(frameNumber, (contour, (x,y,w,h))))
|
||||||
|
|
||||||
self.layers = layers
|
self.layers = layers
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue