From d3b89711022b2ef0ddb58767768715ab27b96c44 Mon Sep 17 00:00:00 2001 From: git Date: Wed, 19 Aug 2020 21:14:26 +0200 Subject: [PATCH] added base --- .gitignore | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ app.py | 59 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 .gitignore create mode 100644 app.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d119013 --- /dev/null +++ b/.gitignore @@ -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/ diff --git a/app.py b/app.py new file mode 100644 index 0000000..40522c5 --- /dev/null +++ b/app.py @@ -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