This commit is contained in:
Askill 2020-12-20 20:58:56 +01:00
parent 6ccf78b54a
commit 8aa8cd1aae
2 changed files with 6 additions and 11 deletions

View File

@ -57,12 +57,12 @@ class ContourExtractor:
# 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:
while not videoReader.videoEnded():
if videoReader.buffer.qsize() == 0:
time.sleep(.1)
if videoReader.buffer.qsize() <= 5:
time.sleep(.5)
tmpData = [videoReader.pop() for i in range(0, videoReader.buffer.qsize())]
self.computeMovingAverage(tmpData)
pool.map_async(self.getContours, tmpData)
pool.map(self.getContours, tmpData)
#for data in tmpData:
# self.getContours(data)
frameCount = tmpData[-1][0]
@ -88,7 +88,6 @@ class ContourExtractor:
#cv2.imshow("changes x", thresh)
#cv2.waitKey(10) & 0XFF
cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
self.diff.append(np.count_nonzero(thresh))
cnts = imutils.grab_contours(cnts)
contours = []
@ -104,8 +103,6 @@ class ContourExtractor:
# meaning every bit in the mask would take up 8bits, which migth be too much
masks.append(np.packbits(np.copy(thresh[y:y+h,x:x+w]), axis=0))
if len(contours) != 0 and contours is not None:
# this should be thread safe
self.extractedContours[frameCount] = contours

View File

@ -14,8 +14,6 @@ import csv
def main(v1, v2, v3, v4):
startTotal = time.time()
start = startTotal
config = Config()
@ -80,10 +78,10 @@ def main(v1, v2, v3, v4):
exit(0)
if __name__ == "__main__":
ass = list(range(1, 18, 4))
bss = list(range(1, 18, 4))
ass = list(range(4, 18, 4))
bss = list(range(4, 18, 4))
css = list(range(1, 16, 8))
dss = list(range(50, 500, 200))
dss = list(range(100, 500, 200))
params = [ass, bss, css, dss]
params = list(product(*params))
counter = 0