added config object, not implemented yet
This commit is contained in:
parent
79cb093df3
commit
ab654d77b4
|
|
@ -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
|
||||
|
|
@ -9,6 +9,7 @@ import traceback
|
|||
import _thread
|
||||
import imageio
|
||||
import numpy as np
|
||||
import time
|
||||
|
||||
class ContourExtractor:
|
||||
|
||||
|
|
@ -32,7 +33,7 @@ class ContourExtractor:
|
|||
threashold = self.threashold
|
||||
|
||||
# initialize the first frame in the video stream
|
||||
vs = VideoCapture(filename)
|
||||
vs = cv2.VideoCapture(videoPath)
|
||||
|
||||
res, image = vs.read()
|
||||
self.xDim = image.shape[1]
|
||||
|
|
@ -41,6 +42,7 @@ class ContourExtractor:
|
|||
# loop over the frames of the video
|
||||
frameCount = 0
|
||||
extractedContours = dict()
|
||||
start = time.time()
|
||||
while res:
|
||||
if frameCount > 25*30*60:
|
||||
break
|
||||
|
|
@ -55,7 +57,7 @@ class ContourExtractor:
|
|||
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
||||
#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 firstFrame is None:
|
||||
|
|
@ -83,9 +85,10 @@ class ContourExtractor:
|
|||
if len(contours) != 0:
|
||||
extractedContours[frameCount] = contours
|
||||
|
||||
if frameCount % (60*30) == 0:
|
||||
print("Minutes processed: ", frameCount/(60*30))
|
||||
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.waitKey(10) & 0XFF
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class LayerFactory:
|
|||
# inserts all the fucking contours as layers?
|
||||
for frameNumber, contours in data.items():
|
||||
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:
|
||||
foundLayer = False
|
||||
|
|
|
|||
2
main.py
2
main.py
|
|
@ -17,7 +17,7 @@ def demo():
|
|||
|
||||
footagePath = os.path.join(os.path.dirname(__file__), "./generate test footage/3.mp4")
|
||||
#analyzer = Analyzer(footagePath)
|
||||
print("Time consumed reading video: ", time.time() - start)
|
||||
#print("Time consumed reading video: ", time.time() - start)
|
||||
contours = ContourExtractor().extractContours(footagePath, resizeWidth)
|
||||
print("Time consumed in working: ", time.time() - start)
|
||||
layerFactory = LayerFactory(contours)
|
||||
|
|
|
|||
Loading…
Reference in New Issue