parent
7baa75dc19
commit
79eb3cefa3
|
|
@ -43,7 +43,6 @@ class ContourExtractor:
|
||||||
self.xDim = 0
|
self.xDim = 0
|
||||||
self.yDim = 0
|
self.yDim = 0
|
||||||
self.config = config
|
self.config = config
|
||||||
self.diff = []
|
|
||||||
self.lastFrames = None
|
self.lastFrames = None
|
||||||
self.averages = dict()
|
self.averages = dict()
|
||||||
|
|
||||||
|
|
@ -97,11 +96,12 @@ class ContourExtractor:
|
||||||
for c in cnts:
|
for c in cnts:
|
||||||
ca = cv2.contourArea(c)
|
ca = cv2.contourArea(c)
|
||||||
(x, y, w, h) = cv2.boundingRect(c)
|
(x, y, w, h) = cv2.boundingRect(c)
|
||||||
#ca = (x+w)*(y+h)
|
|
||||||
if ca < self.min_area or ca > self.max_area:
|
if ca < self.min_area or ca > self.max_area:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
contours.append((x, y, w, h))
|
contours.append((x, y, w, h))
|
||||||
|
# the mask has to be packed like this, since np doesn't have a bit array,
|
||||||
|
# meaning every bit in the mask would take up 8bits, which migth be too much
|
||||||
masks.append(np.packbits(np.copy(thresh[y:y+h,x:x+w]), axis=0))
|
masks.append(np.packbits(np.copy(thresh[y:y+h,x:x+w]), axis=0))
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -121,7 +121,6 @@ class ContourExtractor:
|
||||||
avg = []
|
avg = []
|
||||||
averageFrames = self.config["avgNum"]
|
averageFrames = self.config["avgNum"]
|
||||||
|
|
||||||
nth = int(averageFrames/3) # only take /x x frames to average
|
|
||||||
if frames[0][0] < averageFrames:
|
if frames[0][0] < averageFrames:
|
||||||
frame = frames[0][1]
|
frame = frames[0][1]
|
||||||
frame = self.prepareFrame(frame)
|
frame = self.prepareFrame(frame)
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,12 @@ class Layer:
|
||||||
def add(self, frameNumber, bound, mask):
|
def add(self, frameNumber, bound, mask):
|
||||||
'''Adds a bound to the Layer at the layer index which corresponds to the given framenumber'''
|
'''Adds a bound to the Layer at the layer index which corresponds to the given framenumber'''
|
||||||
index = frameNumber - self.startFrame
|
index = frameNumber - self.startFrame
|
||||||
|
if index < 0:
|
||||||
|
return
|
||||||
if frameNumber > self.lastFrame:
|
if frameNumber > self.lastFrame:
|
||||||
for i in range(frameNumber - self.lastFrame):
|
for i in range(frameNumber - self.lastFrame):
|
||||||
self.bounds.append([bound])
|
self.bounds.append([bound])
|
||||||
self.masks.append([mask])
|
self.masks.append([mask])
|
||||||
|
|
||||||
self.lastFrame = frameNumber
|
self.lastFrame = frameNumber
|
||||||
|
|
||||||
if bound not in self.bounds[index]:
|
if bound not in self.bounds[index]:
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class LayerFactory:
|
||||||
lastBounds = [bound for bounds in layer.bounds[-lastXframes:]
|
lastBounds = [bound for bounds in layer.bounds[-lastXframes:]
|
||||||
for bound in bounds]
|
for bound in bounds]
|
||||||
|
|
||||||
for j, bounds in enumerate(lastBounds[::-1]):
|
for j, bounds in enumerate(sorted(lastBounds, reverse=True)):
|
||||||
if bounds is None:
|
if bounds is None:
|
||||||
break
|
break
|
||||||
(x2, y2, w2, h2) = bounds
|
(x2, y2, w2, h2) = bounds
|
||||||
|
|
|
||||||
Binary file not shown.
3
main.py
3
main.py
|
|
@ -10,9 +10,6 @@ from Application.VideoReader import VideoReader
|
||||||
from Application.LayerManager import LayerManager
|
from Application.LayerManager import LayerManager
|
||||||
from Application.Classifiers import *
|
from Application.Classifiers import *
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
startTotal = time.time()
|
startTotal = time.time()
|
||||||
start = startTotal
|
start = startTotal
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue