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