From bb3a348c8bade0761b1389225af0d7bd86052f63 Mon Sep 17 00:00:00 2001 From: Joel Steffens <joel.steffens@stud.hs-bochum.de> Date: Thu, 7 Sep 2023 17:59:34 +0200 Subject: [PATCH] Kleinere Verbesserungen --- detect_waterstream.py | 24 ++++++++++++++++++------ filters.py | 21 ++++++++++++++++----- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/detect_waterstream.py b/detect_waterstream.py index f6e8af0..d98dabd 100644 --- a/detect_waterstream.py +++ b/detect_waterstream.py @@ -5,7 +5,7 @@ # Erkennung eines Wasserstrahls # # Autoren: - Joel Steffens -# - Mohammend Ka +# - Mohammad Khaleeliyeh # - Midras Lappe ############################################## import cv2 @@ -24,7 +24,18 @@ if argc == 3: skipSeconds = int(sys.argv[2]) capture = cv2.VideoCapture(videoFile) -capture.set(cv2.CAP_PROP_POS_FRAMES, 30 * skipSeconds) + +width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH)) +height = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT)) +fps = int(capture.get(cv2.CAP_PROP_FPS)) +frames = int(capture.get(cv2.CAP_PROP_FRAME_COUNT)) + +skipFrame = fps * skipSeconds +capture.set(cv2.CAP_PROP_POS_FRAMES, skipFrame) + +print(f"Reading video file: {videoFile}") +print(f"Data: {width}x{height}@{fps} Hz") +print(f"Skipping to frame {skipFrame} of total {frames} frames") last = None frame = None @@ -75,9 +86,10 @@ pipeline = [ state = {} # Leeres Dictionary als Zustandsobjekt info = { - 'abs_diff': 2, # Standard: 2+1 Bilder - 'dim': (1920, 1080), # Dimension des Videos - 'params': {} # Leeres Dictionary für Filter-Parameter + 'abs_diff': 2, # Standard: 2+1 Bilder + 'dim': (width, height), # Dimension des Videos + 'scaled': (1280, 720), # Skalierung für die Filter + 'params': {} # Leeres Dictionary für Filter-Parameter } result = None @@ -86,7 +98,7 @@ while capture.isOpened(): # ret is the stat of the reading ret, frame = capture.read() if ret == True: - frame, _ = filters.resize(None, frame, None) + frame, _ = filters.resize(info, frame, None) # Trackbar-Parameter auslesen und setzen info['params']['mix'] = cv2.getTrackbarPos('Diff_Mix', window) / 100.0 diff --git a/filters.py b/filters.py index 80b7471..efa52af 100755 --- a/filters.py +++ b/filters.py @@ -1,3 +1,13 @@ +############################################## +# Modul: Computer Vision (SoSe23) +# Dozent: Prof. Dr-Ing. Gerhardt +# +# Erkennung eines Wasserstrahls +# +# Autoren: - Joel Steffens +# - Mohammad Khaleeliyeh +# - Midras Lappe +############################################## import cv2 as cv import numpy as np import pandas as pd @@ -175,21 +185,22 @@ def green_absfilter(info, image, state): -# Resize image to 1280x720 pixels +# Bild in andere Dimensionen skalieren def resize(info, image, state): - res = cv.resize(image, (1280, 720)) + res = cv.resize(image, info['scaled']) return res, False -# Convert to Gray scale image +# Bild in Graustufen umwandeln def grayscale(info, image, state): res = cv.cvtColor(image, cv.COLOR_BGR2GRAY) return res, False +# Schärfe des Bild erhöhen def median_blur(info, image, state): - # median of all the pixels under the kernel area + # Median-Blur auf Bild anwenden blur = cv.medianBlur(image, 7) - # adding tow images + # beide Bilder zusammenfassen sharp = cv.addWeighted(image, 1.5, blur, -0.5, 0.0) return sharp, False -- GitLab