started working on layers
This commit is contained in:
parent
b45efb1c86
commit
0d928b435c
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
10
Layer.py
10
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")
|
||||
Binary file not shown.
2
main.py
2
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"))
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue