From cb4b02f987958ea848fdbd937b089e1e993f8d9a Mon Sep 17 00:00:00 2001 From: Askill Date: Sun, 20 Dec 2020 22:21:04 +0100 Subject: [PATCH] it's running now --- Application/Config.py | 2 +- Application/ContourExctractor.py | 14 ++++++++++---- bm.csv | 8 +++++--- main.py | 27 +++++++++++++++++++-------- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/Application/Config.py b/Application/Config.py index 0a6fda8..75ff73a 100644 --- a/Application/Config.py +++ b/Application/Config.py @@ -1,7 +1,7 @@ class Config: c = { - "min_area" : 5000, + "min_area" : 10, "max_area" : 40000, "threashold" : 7, "resizeWidth" : 512, diff --git a/Application/ContourExctractor.py b/Application/ContourExctractor.py index 309e793..3273049 100644 --- a/Application/ContourExctractor.py +++ b/Application/ContourExctractor.py @@ -55,21 +55,27 @@ class ContourExtractor: threads = self.config["videoBufferLength"] self.start = time.time() # start a bunch of frames and let them read from the video reader buffer until the video reader reaches EOF - with ThreadPool(self.config["ce_comp_threads"]) as pool: + with ThreadPool(2) as pool: while not videoReader.videoEnded(): if videoReader.buffer.qsize() <= 5: time.sleep(.5) tmpData = [videoReader.pop() for i in range(0, videoReader.buffer.qsize())] - self.computeMovingAverage(tmpData) - pool.map(self.getContours, tmpData) + pool.map(self.computeMovingAverage, (tmpData,)) + pool.map(self.async2, (tmpData,)) + #for data in tmpData: # self.getContours(data) frameCount = tmpData[-1][0] videoReader.thread.join() return self.extractedContours, self.extractedMasks - + + def async2(self, tmpData): + with ThreadPool(self.config["ce_comp_threads"]) as pool2: + pool2.map(self.getContours, tmpData) + + def getContours(self, data): frameCount, frame = data # wait for the reference frame, which is calculated by averaging some revious frames diff --git a/bm.csv b/bm.csv index 89ca9ae..c5e1815 100644 --- a/bm.csv +++ b/bm.csv @@ -1,3 +1,5 @@ -ce_average_threads,ce_comp_threads,lf_threads,videoBufferLength,ce,le,lm,ex -16,16,16,500,0,3.691664457321167,3.737372398376465,0.008670568466186523,3.7460429668426514 - +ce_average_threads,ce_comp_threads,lf_threads,videoBufferLength,ce,le,lm,ex +1,1,16,500,467.52107214927673,1.9164767265319824,0.018573522567749023,49.83112931251526,519.2878699302673 + +1,3,16,500,459.9842381477356,1.716508150100708,0.018574953079223633,48.010451316833496,509.729772567749 +1,5,16,500,446.62813115119934,1.8129642009735107,0.018575429916381836,47.728522539138794,496.188193321228 diff --git a/main.py b/main.py index 14ebc48..d743f68 100644 --- a/main.py +++ b/main.py @@ -61,11 +61,10 @@ def main(v1, v2, v3, v4): #layerManager.tagLayers() layers = layerManager.layers #print([len(l) for l in sorted(layers, key = lambda c:len(c), reverse=True)[:20]]) - if len(layers) == 0: - exit(1) + exporter = Exporter(config) #print(f"Exporting {len(contours)} Contours and {len(layers)} Layers") - #exporter.export(layers, contours, masks, raw=False, overlayed=True) + exporter.export(layers, contours, masks, raw=False, overlayed=True) stats.append(time.time() - start) print("Total time: ", time.time() - startTotal) @@ -75,13 +74,25 @@ def main(v1, v2, v3, v4): writer = csv.writer(myfile) writer.writerow(stats) #print(stats) - exit(0) + if __name__ == "__main__": - ass = list(range(4, 18, 4)) - bss = list(range(4, 18, 4)) - css = list(range(1, 16, 8)) - dss = list(range(100, 500, 200)) + ass = list(range(1, 16, 2)) + bss = list(range(1, 16, 2)) + css = [16] + dss = [500] + params = [ass, bss, css, dss] + params = list(product(*params)) + counter = 0 + for a,b,c,d in params: + print(f"{counter}/{len(params)} - {counter/len(params)} {a, b, c, d}") + counter += 1 + main(a, b, c, d) + + ass = [16] + bss = [16] + css = list(range(1, 16, 4)) + dss = list(range(50, 500, 200)) params = [ass, bss, css, dss] params = list(product(*params)) counter = 0