diff --git a/.gitignore b/.gitignore index bffad8d..e270726 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ __pycache__/ *.mp4 -*.weights \ No newline at end of file +*.weights +*.m4v diff --git a/Application/Classifiers/Classifier.py b/Application/Classifiers/Classifier.py index ad0dc63..8f6ec62 100644 --- a/Application/Classifiers/Classifier.py +++ b/Application/Classifiers/Classifier.py @@ -38,6 +38,8 @@ class Classifier(ClassifierInterface): for cnts in data: for cnt in cnts: if cnt.any(): + cv2.imshow("changes x", cnt) + cv2.waitKey(10) & 0XFF cnt= imutils.resize(cnt, width=320) x = self.detect(cnt) diff --git a/Application/Config.py b/Application/Config.py index d766ef0..7be1d09 100644 --- a/Application/Config.py +++ b/Application/Config.py @@ -1,7 +1,7 @@ class Config: c = { - "min_area" : 500, + "min_area" : 100, "max_area" : 40000, "threashold" : 5, "resizeWidth" : 512, @@ -12,7 +12,7 @@ class Config: "tolerance": 20, "maxLength": None, "ttolerance": 60, - "videoBufferLength": 16, + "videoBufferLength": 500, "noiseThreashold": 0.3, "noiseSensitivity": 3/4, "LayersPerContour": 5, diff --git a/Application/ContourExctractor.py b/Application/ContourExctractor.py index fa6c143..c997e4d 100644 --- a/Application/ContourExctractor.py +++ b/Application/ContourExctractor.py @@ -60,7 +60,7 @@ class ContourExtractor: self.computeMovingAverage(tmpData) pool.map(self.getContours, tmpData) #for data in tmpData: - #self.getContours(data) + # self.getContours(data) frameCount = tmpData[-1][0] videoReader.thread.join() diff --git a/Application/LayerFactory.py b/Application/LayerFactory.py index 49c117e..da584bb 100644 --- a/Application/LayerFactory.py +++ b/Application/LayerFactory.py @@ -25,7 +25,7 @@ class LayerFactory: def extractLayers(self, data = None): '''Bundle given contours together into Layer Objects''' if self.data is None: - if data is None: + if data is None or len(data) == 0 : print("LayerFactory data was none") return None else: diff --git a/Application/LayerManager.py b/Application/LayerManager.py index a191724..ac9db09 100644 --- a/Application/LayerManager.py +++ b/Application/LayerManager.py @@ -25,6 +25,7 @@ class LayerManager: def cleanLayers(self): + print("'Cleaning' Layers") self.freeMin() self.sortLayers() self.cleanLayers2() @@ -69,9 +70,10 @@ class LayerManager: def tagLayers(self): '''Use classifieres the tag all Layers, by reading the contour content from the original video, then applying the classifier''' + print("Tagging Layers") exporter = Exporter(self.config) start = time.time() - for i, layer in enumerate(self.layers): + for i, layer in enumerate(self.layers[20:]): print(f"{round(i/len(self.layers)*100,2)} {round((time.time() - start), 2)}") start = time.time() if len(layer.bounds[0]) == 0: diff --git a/generate test footage/kap.py b/generate test footage/kap.py new file mode 100644 index 0000000..924ec0c --- /dev/null +++ b/generate test footage/kap.py @@ -0,0 +1,34 @@ +#python +import cv2 +import imageio +import time +writer = imageio.get_writer("./x23.mp4", fps=20) + +url = "http://50.227.41.1/mjpg/video.mjpg" +i = 0 +cap = cv2.VideoCapture(url) +while True : + try: + if i < 10: + i+=1 + continue + + + result, frame = cap.read() + + if result == False: + print("Error in cap.read()") # this is for preventing a breaking error + # break; + time.sleep(1) + continue + frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) + writer.append_data(frame) + i+=1 + + if i > 20*60*60: + break + except Exception as e: + + cap.release() + cv2.destroyAllWindows() + writer.close() \ No newline at end of file diff --git a/main.py b/main.py index 61cd80d..ee90f76 100644 --- a/main.py +++ b/main.py @@ -14,9 +14,9 @@ def main(): start = time.time() config = Config() - 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") + config["inputPath"] = os.path.join(os.path.dirname(__file__), "generate test footage/Merica-1.m4v") + #config["importPath"] = os.path.join(os.path.dirname(__file__), "output/short.txt") + config["outputPath"] = os.path.join(os.path.dirname(__file__), "output/shor.mp4") vr = VideoReader(config) config["w"], config["h"] = vr.getWH() @@ -34,7 +34,7 @@ def main(): layerManager = LayerManager(config, layers) layerManager.cleanLayers() - layerManager.tagLayers() + #layerManager.tagLayers() layers = layerManager.layers exporter = Exporter(config) exporter.export(layers, raw=False) diff --git a/ueberblick.drawio.png b/ueberblick.drawio.png new file mode 100644 index 0000000..480ed33 Binary files /dev/null and b/ueberblick.drawio.png differ diff --git a/ueberblick.png b/ueberblick.png new file mode 100644 index 0000000..c0e8b25 Binary files /dev/null and b/ueberblick.png differ