2020-09-22 18:25:06 +00:00
|
|
|
import os
|
|
|
|
|
import time
|
2021-02-04 22:14:07 +00:00
|
|
|
|
|
|
|
|
from Application.Classifiers import *
|
|
|
|
|
from Application.Config import Config
|
2020-10-18 15:36:34 +00:00
|
|
|
from Application.ContourExctractor import ContourExtractor
|
|
|
|
|
from Application.Exporter import Exporter
|
2022-01-09 11:25:22 +00:00
|
|
|
from Application.HeatMap import HeatMap
|
2020-10-18 15:36:34 +00:00
|
|
|
from Application.Importer import Importer
|
2021-02-04 22:14:07 +00:00
|
|
|
from Application.LayerFactory import LayerFactory
|
2020-10-23 22:14:43 +00:00
|
|
|
from Application.LayerManager import LayerManager
|
2021-02-04 22:14:07 +00:00
|
|
|
from Application.VideoReader import VideoReader
|
|
|
|
|
|
2020-09-20 20:01:54 +00:00
|
|
|
|
2020-10-31 19:36:43 +00:00
|
|
|
def main():
|
2020-12-05 19:57:24 +00:00
|
|
|
startTotal = time.time()
|
2020-10-11 15:09:49 +00:00
|
|
|
config = Config()
|
2020-09-24 13:47:49 +00:00
|
|
|
|
2022-05-03 08:57:19 +00:00
|
|
|
fileName = "./x23-1.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)
|
2021-02-04 22:14:07 +00:00
|
|
|
config["outputPath"] = os.path.join(outputPath, fileName)
|
2022-01-09 19:25:44 +00:00
|
|
|
config["importPath"] = os.path.join(outputPath, fileName.split(".")[0] + ".txt")
|
2020-11-08 15:28:47 +00:00
|
|
|
config["w"], config["h"] = VideoReader(config).getWH()
|
2020-12-22 12:58:47 +00:00
|
|
|
|
2020-11-08 15:28:47 +00:00
|
|
|
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
|
|
|
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-12-22 12:58:47 +00:00
|
|
|
layerFactory = LayerFactory(config)
|
|
|
|
|
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)
|
2022-05-03 08:57:19 +00:00
|
|
|
layerManager.cleanLayers()
|
2020-12-22 12:58:47 +00:00
|
|
|
|
2022-01-09 19:25:44 +00:00
|
|
|
# layerManager.tagLayers()
|
2020-10-31 19:36:43 +00:00
|
|
|
layers = layerManager.layers
|
2020-12-18 20:27:19 +00:00
|
|
|
if len(layers) == 0:
|
|
|
|
|
exit(1)
|
2020-12-26 13:58:58 +00:00
|
|
|
|
2022-05-03 08:57:19 +00:00
|
|
|
heatmap = HeatMap(config["w"], config["h"], [contour for layer in layers for contour in layer.bounds], 1920 / config["resizeWidth"])
|
2022-01-09 11:25:22 +00:00
|
|
|
heatmap.showImage()
|
|
|
|
|
|
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-12-20 14:49:43 +00:00
|
|
|
exporter.export(layers, contours, masks, raw=True, overlayed=True)
|
2020-12-05 19:57:24 +00:00
|
|
|
print("Total time: ", time.time() - startTotal)
|
2020-10-05 20:24:38 +00:00
|
|
|
|
2021-02-04 22:14:07 +00:00
|
|
|
|
2020-09-20 20:01:54 +00:00
|
|
|
if __name__ == "__main__":
|
2020-10-31 19:36:43 +00:00
|
|
|
main()
|