added doc and kap.py
This commit is contained in:
parent
82e708ff94
commit
01b5d7f9a9
|
|
@ -10,3 +10,4 @@ __pycache__/
|
||||||
*.mp4
|
*.mp4
|
||||||
|
|
||||||
*.weights
|
*.weights
|
||||||
|
*.m4v
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ class Classifier(ClassifierInterface):
|
||||||
for cnts in data:
|
for cnts in data:
|
||||||
for cnt in cnts:
|
for cnt in cnts:
|
||||||
if cnt.any():
|
if cnt.any():
|
||||||
|
cv2.imshow("changes x", cnt)
|
||||||
|
cv2.waitKey(10) & 0XFF
|
||||||
cnt= imutils.resize(cnt, width=320)
|
cnt= imutils.resize(cnt, width=320)
|
||||||
x = self.detect(cnt)
|
x = self.detect(cnt)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
c = {
|
c = {
|
||||||
"min_area" : 500,
|
"min_area" : 100,
|
||||||
"max_area" : 40000,
|
"max_area" : 40000,
|
||||||
"threashold" : 5,
|
"threashold" : 5,
|
||||||
"resizeWidth" : 512,
|
"resizeWidth" : 512,
|
||||||
|
|
@ -12,7 +12,7 @@ class Config:
|
||||||
"tolerance": 20,
|
"tolerance": 20,
|
||||||
"maxLength": None,
|
"maxLength": None,
|
||||||
"ttolerance": 60,
|
"ttolerance": 60,
|
||||||
"videoBufferLength": 16,
|
"videoBufferLength": 500,
|
||||||
"noiseThreashold": 0.3,
|
"noiseThreashold": 0.3,
|
||||||
"noiseSensitivity": 3/4,
|
"noiseSensitivity": 3/4,
|
||||||
"LayersPerContour": 5,
|
"LayersPerContour": 5,
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class LayerFactory:
|
||||||
def extractLayers(self, data = None):
|
def extractLayers(self, data = None):
|
||||||
'''Bundle given contours together into Layer Objects'''
|
'''Bundle given contours together into Layer Objects'''
|
||||||
if self.data is None:
|
if self.data is None:
|
||||||
if data is None:
|
if data is None or len(data) == 0 :
|
||||||
print("LayerFactory data was none")
|
print("LayerFactory data was none")
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ class LayerManager:
|
||||||
|
|
||||||
|
|
||||||
def cleanLayers(self):
|
def cleanLayers(self):
|
||||||
|
print("'Cleaning' Layers")
|
||||||
self.freeMin()
|
self.freeMin()
|
||||||
self.sortLayers()
|
self.sortLayers()
|
||||||
self.cleanLayers2()
|
self.cleanLayers2()
|
||||||
|
|
@ -69,9 +70,10 @@ class LayerManager:
|
||||||
|
|
||||||
def tagLayers(self):
|
def tagLayers(self):
|
||||||
'''Use classifieres the tag all Layers, by reading the contour content from the original video, then applying the classifier'''
|
'''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)
|
exporter = Exporter(self.config)
|
||||||
start = time.time()
|
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)}")
|
print(f"{round(i/len(self.layers)*100,2)} {round((time.time() - start), 2)}")
|
||||||
start = time.time()
|
start = time.time()
|
||||||
if len(layer.bounds[0]) == 0:
|
if len(layer.bounds[0]) == 0:
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
8
main.py
8
main.py
|
|
@ -14,9 +14,9 @@ def main():
|
||||||
start = time.time()
|
start = time.time()
|
||||||
config = Config()
|
config = Config()
|
||||||
|
|
||||||
config["inputPath"] = os.path.join(os.path.dirname(__file__), "generate test footage/3.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["importPath"] = os.path.join(os.path.dirname(__file__), "output/short.txt")
|
||||||
config["outputPath"] = os.path.join(os.path.dirname(__file__), "output/short.mp4")
|
config["outputPath"] = os.path.join(os.path.dirname(__file__), "output/shor.mp4")
|
||||||
|
|
||||||
vr = VideoReader(config)
|
vr = VideoReader(config)
|
||||||
config["w"], config["h"] = vr.getWH()
|
config["w"], config["h"] = vr.getWH()
|
||||||
|
|
@ -34,7 +34,7 @@ def main():
|
||||||
layerManager = LayerManager(config, layers)
|
layerManager = LayerManager(config, layers)
|
||||||
layerManager.cleanLayers()
|
layerManager.cleanLayers()
|
||||||
|
|
||||||
layerManager.tagLayers()
|
#layerManager.tagLayers()
|
||||||
layers = layerManager.layers
|
layers = layerManager.layers
|
||||||
exporter = Exporter(config)
|
exporter = Exporter(config)
|
||||||
exporter.export(layers, raw=False)
|
exporter.export(layers, raw=False)
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 311 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 219 KiB |
Loading…
Reference in New Issue