added config object, not implemented yet

This commit is contained in:
Askill 2020-10-07 15:07:01 +02:00
parent 79cb093df3
commit ab654d77b4
4 changed files with 35 additions and 6 deletions

26
Config.py Normal file
View File

@ -0,0 +1,26 @@
class Config:
c = {
"min_area" : 500,
"max_area" : 28000,
"threashold" : 13,
"xDim" : 0,
"yDim" : 0,
"resizeWidth" : 512,
"inputPath" : "",
"outputPath": "",
"maxLayerLength": 1000,
"minLayerLength": 0,
"fps": 30,
"tolerance": 5,
"maxLength": None,
""
}
__init__(self):
print(Current Config:)
def __getitem__(self, key):
return self.c[key]
def __setitem__(self, key, value):
return self.c[key] = value

View File

@ -9,6 +9,7 @@ import traceback
import _thread import _thread
import imageio import imageio
import numpy as np import numpy as np
import time
class ContourExtractor: class ContourExtractor:
@ -32,7 +33,7 @@ class ContourExtractor:
threashold = self.threashold threashold = self.threashold
# initialize the first frame in the video stream # initialize the first frame in the video stream
vs = VideoCapture(filename) vs = cv2.VideoCapture(videoPath)
res, image = vs.read() res, image = vs.read()
self.xDim = image.shape[1] self.xDim = image.shape[1]
@ -41,6 +42,7 @@ class ContourExtractor:
# loop over the frames of the video # loop over the frames of the video
frameCount = 0 frameCount = 0
extractedContours = dict() extractedContours = dict()
start = time.time()
while res: while res:
if frameCount > 25*30*60: if frameCount > 25*30*60:
break break
@ -55,7 +57,7 @@ class ContourExtractor:
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
#gray = np.asarray(gray[:,:,1]/3 + gray[:,:,2]/3 + gray[:,:,0]/6).astype(np.uint8) #gray = np.asarray(gray[:,:,1]/3 + gray[:,:,2]/3 + gray[:,:,0]/6).astype(np.uint8)
gray = cv2.GaussianBlur(gray, (5, 5), 0) gray = cv2.GaussianBlur(gray, (10, 10), 0)
# if the first frame is None, initialize it # if the first frame is None, initialize it
if firstFrame is None: if firstFrame is None:
@ -83,9 +85,10 @@ class ContourExtractor:
if len(contours) != 0: if len(contours) != 0:
extractedContours[frameCount] = contours extractedContours[frameCount] = contours
if frameCount % (60*30) == 0:
print("Minutes processed: ", frameCount/(60*30))
frameCount += 1 frameCount += 1
if frameCount % (60*30) == 0:
print(f"{frameCount/(60*30)} Minutes processed at {round((time.time() - start)/(frameCount/(30*60)), 2)}s per minute")
#cv2.imshow( "annotated", thresh ) #cv2.imshow( "annotated", thresh )
#cv2.waitKey(10) & 0XFF #cv2.waitKey(10) & 0XFF

View File

@ -53,7 +53,7 @@ class LayerFactory:
# inserts all the fucking contours as layers? # inserts all the fucking contours as layers?
for frameNumber, contours in data.items(): for frameNumber, contours in data.items():
if frameNumber%5000 == 0: if frameNumber%5000 == 0:
print(frameNumber/max(data.keys())) print(f"{round(frameNumber/max(data.keys()), 2)}% done with Layer extraction")
for (x,y,w,h) in contours: for (x,y,w,h) in contours:
foundLayer = False foundLayer = False

View File

@ -17,7 +17,7 @@ def demo():
footagePath = os.path.join(os.path.dirname(__file__), "./generate test footage/3.mp4") footagePath = os.path.join(os.path.dirname(__file__), "./generate test footage/3.mp4")
#analyzer = Analyzer(footagePath) #analyzer = Analyzer(footagePath)
print("Time consumed reading video: ", time.time() - start) #print("Time consumed reading video: ", time.time() - start)
contours = ContourExtractor().extractContours(footagePath, resizeWidth) contours = ContourExtractor().extractContours(footagePath, resizeWidth)
print("Time consumed in working: ", time.time() - start) print("Time consumed in working: ", time.time() - start)
layerFactory = LayerFactory(contours) layerFactory = LayerFactory(contours)