Video-Summary/main.py

54 lines
1.8 KiB
Python
Raw Normal View History

2020-09-22 18:25:06 +00:00
import os
import time
2020-10-18 15:36:34 +00:00
from Application.ContourExctractor import ContourExtractor
from Application.Exporter import Exporter
from Application.LayerFactory import LayerFactory
from Application.Analyzer import Analyzer
from Application.Config import Config
from Application.Importer import Importer
from Application.VideoReader import VideoReader
2020-10-23 22:14:43 +00:00
from Application.LayerManager import LayerManager
from Application.Classifiers import *
2020-09-20 20:01:54 +00:00
2020-10-31 19:36:43 +00:00
def main():
2020-09-22 18:25:06 +00:00
start = time.time()
2020-10-11 15:09:49 +00:00
config = Config()
2020-09-24 13:47:49 +00:00
2020-11-27 00:06:25 +00:00
fileName = "3.mp4"
2020-11-08 15:28:47 +00:00
outputPath = os.path.join(os.path.dirname(__file__), "output")
dirName = os.path.join(os.path.dirname(__file__), "generate test footage")
2020-10-16 08:36:52 +00:00
2020-11-08 15:28:47 +00:00
config["inputPath"] = os.path.join(dirName, fileName)
config["outputPath"] = os.path.join(outputPath, fileName)
2020-10-18 15:36:34 +00:00
2020-11-08 15:28:47 +00:00
config["importPath"] = os.path.join(outputPath, fileName.split(".")[0] + ".txt")
config["w"], config["h"] = VideoReader(config).getWH()
if not os.path.exists(config["importPath"]):
2020-11-27 00:06:25 +00:00
contours, masks = ContourExtractor(config).extractContours()
2020-10-16 08:36:52 +00:00
print("Time consumed extracting: ", time.time() - start)
layerFactory = LayerFactory(config)
2020-11-27 00:06:25 +00:00
layers = layerFactory.extractLayers(contours, masks)
2020-10-16 08:36:52 +00:00
else:
2020-11-27 00:06:25 +00:00
layers, contours, masks = Importer(config).importRawData()
2020-11-12 17:59:57 +00:00
layerFactory = LayerFactory(config)
2020-11-27 00:06:25 +00:00
layers = layerFactory.extractLayers(contours, masks)
2020-10-16 08:36:52 +00:00
2020-10-31 19:36:43 +00:00
layerManager = LayerManager(config, layers)
layerManager.transformLayers()
2020-10-31 19:36:43 +00:00
2020-11-05 22:17:05 +00:00
#layerManager.tagLayers()
2020-10-31 19:36:43 +00:00
layers = layerManager.layers
2020-10-16 08:36:52 +00:00
exporter = Exporter(config)
2020-11-08 15:28:47 +00:00
print(f"Exporting {len(contours)} Contours and {len(layers)} Layers")
2020-11-21 18:13:17 +00:00
exporter.export(layers, contours, raw=True, overlayed=True)
2020-10-16 08:36:52 +00:00
2020-10-03 22:27:36 +00:00
print("Total time: ", time.time() - start)
exit(0)
2020-10-05 20:24:38 +00:00
2020-09-20 20:01:54 +00:00
if __name__ == "__main__":
2020-10-31 19:36:43 +00:00
main()
2020-09-22 18:25:06 +00:00