diff --git a/ContourExctractor.py b/ContourExctractor.py index 57bb7ab..e22f638 100644 --- a/ContourExctractor.py +++ b/ContourExctractor.py @@ -78,6 +78,19 @@ class ContourExtractor: #cv2.waitKey(10) & 0XFF def displayContours(self): + values = self.extractedContours.values() + for xx in values: + for v1 in xx: + (x, y, w, h) = v1[1] + v = v1[0] + frame = np.zeros(shape=[self.yDim, self.xDim, 3], dtype=np.uint8) + frame = imutils.resize(frame, width=512) + frame[y:y+v.shape[0], x:x+v.shape[1]] = v + cv2.imshow("changes overlayed", frame) + cv2.waitKey(10) & 0XFF + cv2.destroyAllWindows() + + def exportContours(self): values = self.extractedContours.values() frames = [] for xx in values: @@ -86,14 +99,7 @@ class ContourExtractor: v = v1[0] frame = np.zeros(shape=[self.yDim, self.xDim, 3], dtype=np.uint8) frame = imutils.resize(frame, width=512) - #cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2) - frame[y:y+v.shape[0], x:x+v.shape[1]] = v frames.append(frame) - - #cv2.imshow("changes overlayed", frame) - #cv2.waitKey(10) & 0XFF - #cv2.waitKey(0) - #cv2.destroyAllWindows() return frames diff --git a/Exporter.py b/Exporter.py index 69dff46..e4969a5 100644 --- a/Exporter.py +++ b/Exporter.py @@ -11,5 +11,4 @@ class Exporter: writer = imageio.get_writer(outputPath, fps=fps) for frame in frames: writer.append_data(np.array(frame)) - writer.close() diff --git a/Layer.py b/Layer.py index b2b446b..676cee4 100644 --- a/Layer.py +++ b/Layer.py @@ -1,3 +1,11 @@ class Layer: - def __init__(self): + #data = [(contour, (x,y,w,h)),] + data = [] + startFrame = 0 + backgroundImage = [] + def __init__(self, startFrame, data, backgroundImage): + self.startFrame = startFrame + self.data = data + self.backgroundImage = backgroundImage + print("Layer constructed") \ No newline at end of file diff --git a/__pycache__/ContourExctractor.cpython-37.pyc b/__pycache__/ContourExctractor.cpython-37.pyc index 9da8d1d..ae032db 100644 Binary files a/__pycache__/ContourExctractor.cpython-37.pyc and b/__pycache__/ContourExctractor.cpython-37.pyc differ diff --git a/main.py b/main.py index 0f72857..5df723f 100644 --- a/main.py +++ b/main.py @@ -16,7 +16,7 @@ def demo(): contourExtractor = ContourExtractor(footagePath) print("Time consumed in working: ",time.time() - start) - frames = contourExtractor.displayContours() + frames = contourExtractor.exportContours() Exporter().export(frames,os.path.join(os.path.dirname(__file__), "./short.mp4"))