added base

master
git 2020-08-19 21:14:26 +02:00
parent d647d0981b
commit d3b8971102
2 changed files with 136 additions and 0 deletions

77
.gitignore vendored Normal file
View File

@ -0,0 +1,77 @@
# Created by .ignore support plugin (hsz.mobi)
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
*.manifest
*.spec
pip-log.txt
pip-delete-this-directory.txt
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
*.mo
*.pot
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
instance/
.webassets-cache
.scrapy
docs/_build/
.pybuilder/
target/
.ipynb_checkpoints
profile_default/
ipython_config.py
__pypackages__/
celerybeat-schedule
celerybeat.pid
*.sage.py
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
.spyderproject
.spyproject
.ropeproject
/site
.mypy_cache/
.dmypy.json
dmypy.json
.pyre/
.pytype/
cython_debug/
/data/

59
app.py Normal file
View File

@ -0,0 +1,59 @@
import cv2
import os
import math
import numpy as np
import matplotlib.pyplot as plt
# Create the temp dir
if not os.path.exists('data'):
os.makedirs('data')
# Define the color spaces
Red_lower2 = np.array([,100,100])
Red_upper2 = np.array([,255,255])
Red_lower1 = np.array([0,100,100])
Red_upper1 = np.array([6,255,255])
Orange_lower = np.array([7,100,100])
Orange_upper = np.array([22,255,255])
Yellow_lower = np.array([23,100,100])
Yellow_upper = np.array([32,255,255])
Green_lower = np.array([33,100,100])
Green_upper = np.array([75,255,255])
Cyan_lower = np.array([76,100,100])
Cyan_upper = np.array([97,255,255])
Blue_lower = np.array([93,100,100])
Blue_upper = np.array([130,255,255])
Purple_lower = np.array([130,100,100])
Purple_upper = np.array([,255,255])
Pink_lower = np.array([,100,100])
Pink_upper = np.array([,255,255])
White_lower = np.array([,100,100])
White_upper = np.array([,255,255])
Black_lower = np.array([,100,100])
Black_upper = np.array([,255,255])
# loop through video files
videopath = '/media/vm/HDD/freeloops/3D/'
imagepath = 'data/'
videos = os.listdir(videopath)
for video in videos:
cap = cv2.VideoCapture(videopath + video)
framerate = cap.get(cv2.CAP_PROP_FPS)
while cap.isOpened():
frameId = cap.get(1)
ret, frame = cap.read()
if not ret:
break
if frameId % math.floor(framerate) == 0:
filename = imagepath + "/screenshot_" + str(int(frameId)) + ".jpg"
cv2.imwrite(filename, frame)
del cap
# analyze each screenshot for colors
images = os.listdir(imagepath)
for image in images:
cap = cv2.imread(imagepath + image, cv2.COLOR_BGR2HSV)
plt.imshow(cap)
# move video file according to results