Video-Summary/Exporter.py

36 lines
1.1 KiB
Python
Raw Normal View History

import imageio
2020-09-25 17:52:41 +00:00
import imutils
import numpy as np
2020-09-25 17:52:41 +00:00
from Layer import Layer
import cv2
2020-09-20 20:01:54 +00:00
class Exporter:
fps = 30
2020-09-24 13:47:49 +00:00
def __init__(self):
print("Exporter initiated")
2020-09-24 13:47:49 +00:00
def export(self, frames, outputPath):
fps = self.fps
writer = imageio.get_writer(outputPath, fps=fps)
2020-09-24 13:47:49 +00:00
for frame in frames:
writer.append_data(np.array(frame))
2020-09-24 13:47:49 +00:00
writer.close()
2020-09-25 17:52:41 +00:00
def exportLayers(self, layers, outputPath):
2020-09-28 20:28:23 +00:00
fps = self.fps
writer = imageio.get_writer(outputPath, fps=fps)
2020-09-25 17:52:41 +00:00
for layer in layers:
data = layer.data
for frame in data:
(x, y, w, h) = frame[1]
frame = frame[0]
frame1 = np.zeros(shape=[1080, 1920, 3], dtype=np.uint8)
frame1 = imutils.resize(frame1, width=512)
frame1[y:y+frame.shape[0], x:x+frame.shape[1]] = frame
writer.append_data(np.array(frame1))
2020-09-28 20:28:23 +00:00
#cv2.imshow("changes overlayed", frame)
#cv2.waitKey(10) & 0XFF
2020-09-25 17:52:41 +00:00
2020-09-28 20:28:23 +00:00
writer.close()
#cv2.destroyAllWindows()