From 0d928b435cde04ca301823aefde1ec5fb9e9ed4c Mon Sep 17 00:00:00 2001 From: Askill Date: Thu, 24 Sep 2020 17:14:59 +0200 Subject: [PATCH] started working on layers --- ContourExctractor.py | 20 ++++++++++++------- Exporter.py | 1 - Layer.py | 10 +++++++++- __pycache__/ContourExctractor.cpython-37.pyc | Bin 2242 -> 2793 bytes main.py | 2 +- 5 files changed, 23 insertions(+), 10 deletions(-) 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 9da8d1d0ea5dda79971e27d3dca970e7885a0652..ae032db439b21e9f8c0b6bf2f5e81c2e4f93ee63 100644 GIT binary patch delta 1068 zcmZ8f&re%N5Z>AM``LamCXm{wwLw+kl@JsuX_GXnXwo!Nkx(R}AfeF8Vjqo-;|Kd5 zV61&2QqtTSfwo5uxQAYQ$tj0c>a}We=q2)hkUycf%vgl9ywT44X7-!i*_rus=*>uQ zqfqb}exLo?`u=6%Aov5mJb3weUieSga$e*XS(w)z%myRKadF+mmHeW=fqP$ktL%M{ zhsrv#d+a{X?95lbVC$~zrc9WR0hnNmEcKf?^jpIIiD!Ol9_59jU%}WJR~S7b%PDsd z^Sk~R#>!r5HcLHI@G{E^h=)}{FyV`wp5ft)RKeG5rI{7+l(H)JK=F094@u?3Hr7qd z>Bc^6R`g>&hX#Vb_^pX)m7{6b+8Se=YhoJCisx&F1UyT^aKzXh=C(xlow$X`~jzi`z5%ff3qfU zQ-QsAwR?_0u_il$9?PI}r~sezbH+Q*6i4(lGn65q%Nxfwa-r9a?=*Z~qV_wRk&{t@>^x-cX37 zCx?M7Q=GkBZ*4_MpSL&qRyUGyB8Q1nqD^b7(N3?(v*e&T8(byN5E@0b?CjJV>3p=i zJR~khNh;&ruUf68Mq9)?N$AT85kEoI=bcWUZ(o!jlIJ5*RZ=xwb*8I#5GHgU!xoYh zv56II;1srT6m-Lx(0^P1?8%Rj^4|xBxxpI-SI9}+lvAWm@|Pi*r?US5eHi#YH+wK` ziTsqv)1*#kNxt(8FOUww@e?(Hs2@a~jaa6~Q=F{md8Zs=?j`6}PmlJ6|8p0@f_~;q sLs`FYChQqHcUC`g&()-XIKY)qA6&!6K|U7lUU3V$~L|0mjMXX#fBK delta 562 zcmY+A&ubGw6vyYy%uY6wWKFgvHq@V?Vnb08p<1yj{<;YDP*GSEDV;5(i80P@Vw7Dx zsV5=jT|9_1|A0q53LXUo52ECtXa5Hez6~Nc!~4wl``(*jW`0#aRJ@C&l4dmKUv=(& zEpB`7VQKsGDY?d)8Y^(zt5MCRxI_`X##Oj^@@k?+U|%NAjvBMuJXNVqv|(-6TEo^@ zthWl}rEy;HRL63sXcYd0xm`IU#v&~w?zHzU=J{ORjpddV2}Y(juP#CNFSJNZmaWE>7-Tybukl*j@|r9|4YZ&R zI7pp79OD{4IY;n!?&FidG4Z2b*kYWqCRjy3)-2drS|)0+-sy+Ygm-&^^EkBkBRfNR z>k|T}-|EJv?d~j5%}~j(hd|rwnVu(1)TUj(7e)ae4g)?oVfSX0eHr#=IDpS{i*O4& z`MM((z*qPs*AT1CBEHEl!YoemjirUG@zDQhWL6M7il|I*g`&6ro!mW-%laA|#;4l+ E0a6}!NdN!< 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"))