contour export and import
This commit is contained in:
parent
73d1ddc74b
commit
f907094d1a
|
|
@ -19,6 +19,8 @@ class Config:
|
|||
print("Current Config:", self.c)
|
||||
|
||||
def __getitem__(self, key):
|
||||
if key not in self.c:
|
||||
return None
|
||||
return self.c[key]
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import numpy as np
|
|||
from Layer import Layer
|
||||
import cv2
|
||||
from VideoReader import VideoReader
|
||||
|
||||
import pickle
|
||||
|
||||
class Exporter:
|
||||
fps = 30
|
||||
|
|
@ -105,6 +105,11 @@ class Exporter:
|
|||
|
||||
writer.close()
|
||||
|
||||
def exportRawData(self, layers):
|
||||
with open(self.outputPath.split(".")[-2] + ".txt", "wb+") as file:
|
||||
pickle.dump(layers, file)
|
||||
|
||||
|
||||
def getMaxLengthOfLayers(self, layers):
|
||||
maxLength = 0
|
||||
for layer in layers:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
import pickle
|
||||
|
||||
class Importer:
|
||||
def __init__(self, config):
|
||||
self.path = config["importPath"]
|
||||
|
||||
def importRawData(self):
|
||||
with open(self.path, "rb") as file:
|
||||
layers = pickle.load(file)
|
||||
return layers
|
||||
22
main.py
22
main.py
|
|
@ -6,6 +6,7 @@ from LayerFactory import LayerFactory
|
|||
from Analyzer import Analyzer
|
||||
from VideoReader import VideoReader
|
||||
from Config import Config
|
||||
from Importer import Importer
|
||||
import cv2
|
||||
#TODO
|
||||
# finden von relevanten Stellen anhand von zu findenen metriken für vergleichsbilder
|
||||
|
|
@ -15,15 +16,22 @@ def demo():
|
|||
start = time.time()
|
||||
config = Config()
|
||||
|
||||
config["inputPath"] = os.path.join(os.path.dirname(__file__), "./generate test footage/out.mp4")
|
||||
config["outputPath"] = os.path.join(os.path.dirname(__file__), "./output/short.mp4")
|
||||
config["inputPath"] = os.path.join(os.path.dirname(__file__), "generate test footage/3.mp4")
|
||||
#config["importPath"] = os.path.join(os.path.dirname(__file__), "output/short.txt")
|
||||
config["outputPath"] = os.path.join(os.path.dirname(__file__), "output/short.mp4")
|
||||
|
||||
contours = ContourExtractor(config).extractContours()
|
||||
print("Time consumed extracting: ", time.time() - start)
|
||||
layerFactory = LayerFactory(config)
|
||||
layers = layerFactory.extractLayers(contours)
|
||||
if config["importPath"] is None:
|
||||
contours = ContourExtractor(config).extractContours()
|
||||
print("Time consumed extracting: ", time.time() - start)
|
||||
layerFactory = LayerFactory(config)
|
||||
layers = layerFactory.extractLayers(contours)
|
||||
else:
|
||||
layers = Importer(config).importRawData()
|
||||
|
||||
exporter = Exporter(config)
|
||||
exporter.exportRawData(layers)
|
||||
exporter.exportOverlayed(layers)
|
||||
|
||||
Exporter(config).exportOverlayed(layers)
|
||||
print("Total time: ", time.time() - start)
|
||||
|
||||
def init():
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue