added doc and kap.py

This commit is contained in:
Askill 2020-11-05 23:17:05 +01:00
parent 82e708ff94
commit 01b5d7f9a9
10 changed files with 49 additions and 10 deletions

3
.gitignore vendored
View File

@ -9,4 +9,5 @@ __pycache__/
*.mp4
*.weights
*.weights
*.m4v

View File

@ -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)

View File

@ -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,

View File

@ -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()

View File

@ -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:

View File

@ -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:

View File

@ -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()

View File

@ -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)

BIN
ueberblick.drawio.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 KiB

BIN
ueberblick.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 KiB