added layer id to output

This commit is contained in:
Askill 2020-09-29 22:52:36 +02:00
parent 31974e4d68
commit 0ce61c655a
7 changed files with 9 additions and 3 deletions

View File

@ -17,7 +17,7 @@ class ContourExtractor:
extractedContours = dict() extractedContours = dict()
min_area = 200 min_area = 200
max_area = 30000 max_area = 30000
threashold = 25 threashold = 35
xDim = 0 xDim = 0
yDim = 0 yDim = 0

View File

@ -19,17 +19,22 @@ class Exporter:
def exportLayers(self, layers, outputPath): def exportLayers(self, layers, outputPath):
fps = self.fps fps = self.fps
writer = imageio.get_writer(outputPath, fps=fps) writer = imageio.get_writer(outputPath, fps=fps)
i=0
for layer in layers: for layer in layers:
data = layer.data data = layer.data
if len(data) < 10:
continue
for frame in data: for frame in data:
(x, y, w, h) = frame[1] (x, y, w, h) = frame[1]
frame = frame[0] frame = frame[0]
frame1 = np.zeros(shape=[1080, 1920, 3], dtype=np.uint8) frame1 = np.zeros(shape=[1080, 1920, 3], dtype=np.uint8)
frame1 = imutils.resize(frame1, width=512) frame1 = imutils.resize(frame1, width=512)
frame1[y:y+frame.shape[0], x:x+frame.shape[1]] = frame frame1[y:y+frame.shape[0], x:x+frame.shape[1]] = frame
cv2.putText(frame1, str(i), (30,30), cv2.FONT_HERSHEY_SIMPLEX, 1,(255,255,255), 2)
writer.append_data(np.array(frame1)) writer.append_data(np.array(frame1))
#cv2.imshow("changes overlayed", frame) #cv2.imshow("changes overlayed", frame)
#cv2.waitKey(10) & 0XFF #cv2.waitKey(10) & 0XFF
i += 1
writer.close() writer.close()
#cv2.destroyAllWindows() #cv2.destroyAllWindows()

View File

@ -3,7 +3,7 @@ from Layer import Layer
class LayerFactory: class LayerFactory:
data = {} data = {}
layers = [] layers = []
tolerance = 10 tolerance = -10
def __init__(self, data=None): def __init__(self, data=None):
print("LayerFactory constructed") print("LayerFactory constructed")
self.data = data self.data = data
@ -40,11 +40,12 @@ class LayerFactory:
print("LayerFactory: Layer knew no bounds") print("LayerFactory: Layer knew no bounds")
continue continue
if frameNumber - layer.lastFrame <= 1: if frameNumber - layer.lastFrame <= 20:
(x2,y2,w2,h2) = layer.data[-1][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)): if self.contoursOverlay((x-tol,y+h+tol), (x+w+tol,y-tol), (x2,y2+h2), (x2+w2,y2)):
foundLayer = True foundLayer = True
layer.add(frameNumber, (contour, (x,y,w,h))) layer.add(frameNumber, (contour, (x,y,w,h)))
break
layers[i] = layer layers[i] = layer
if not foundLayer: if not foundLayer:

Binary file not shown.

BIN
short.mp4

Binary file not shown.