Browse Source

test case record gefixxt und alte facedetect hinzugefügt

master
Roberto Gelsinger 11 months ago
parent
commit
7704a34b1c

BIN
code/__pycache__/constants.cpython-310.pyc View File


BIN
code/__pycache__/eulerian.cpython-310.pyc View File


BIN
code/__pycache__/excel_processing.cpython-310.pyc View File


BIN
code/__pycache__/excel_update.cpython-310.pyc View File


BIN
code/__pycache__/facedetection.cpython-310.pyc View File


BIN
code/__pycache__/heartrate.cpython-310.pyc View File


BIN
code/__pycache__/processing.cpython-310.pyc View File


BIN
code/__pycache__/pyramids.cpython-310.pyc View File


BIN
code/__pycache__/recording.cpython-310.pyc View File


+ 61
- 0
code/facedetection2.py View File

"""
Abhängigkeiten:
- cv2 (OpenCV-Paket)
- numpy

Autor: Ihr Name
Datum: Erstellungs- oder Änderungsdatum
Version: Modulversion
"""

import cv2
import numpy as np

faceCascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_alt2.xml")

def read_video(path):
"""
Liest ein Video, erkennt Gesichter und extrahiert Regionen von Interesse (ROIs).

Diese Funktion nimmt einen Pfad zu einer Videodatei und liest das Video. Während des Lesens erkennt sie
Gesichter im Video und extrahiert die ROIs (Gesichtsbereiche), die anschließend in einer Liste von Frames
gespeichert werden. Die Frames werden für spätere Verarbeitungsschritte skaliert.

Args:
path (str): Der Pfad zur Videodatei.

Returns:
tuple: Ein Tupel, bestehend aus:
- video_frames (list): Eine Liste von Frames, die die ROIs (Gesichtsbereiche) darstellen.
- frame_ct (int): Die Anzahl der extrahierten Frames.
- fps (int): Die Bildrate (Frames pro Sekunde) des Videos.
"""
cap = cv2.VideoCapture(path)
fps = int(cap.get(cv2.CAP_PROP_FPS))
video_frames = []

while cap.isOpened():
ret, img = cap.read()
if not ret:
break

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# Detect faces
faces = faceCascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30))
# Extract ROIs and resize
for (x, y, w, h) in faces:
face_roi = cv2.resize(img[y:y+h, x:x+w], (500, 500))
frame = face_roi.astype("float") / 255.0
video_frames.append(frame)

cap.release()


for frame in video_frames:
cv2.imshow("frame", frame)
cv2.waitKey(20)
cv2.destroyAllWindows()
return video_frames, len(video_frames), fps

+ 21
- 15
code/main.py View File





current_dir = os.getcwd() current_dir = os.getcwd()
testcase_excel_file_path = os.path.join(current_dir, 'testing/excel/Testcase_excel_dataset.xlsx')
testruns_excel_file_path = os.path.join(current_dir, 'testing/excel/Testruns.xlsx')
testcase_excel_file_path = os.path.join(current_dir, 'code/testing/excel/Testcase_excel_dataset.xlsx')
testruns_excel_file_path = os.path.join(current_dir, 'code/testing/excel/Testruns.xlsx')


class VideoProcessingApp(tk.Tk): class VideoProcessingApp(tk.Tk):
def __init__(self): def __init__(self):




def check_recording_status(self): def check_recording_status(self):
excel_file_path = 'testing/excel/Testcase_excel_dataset.xlsx'
global recording_finished # Deklarieren Sie die Verwendung der globalen Variable
excel_file_path = 'code/testing/excel/Testcase_excel_dataset.xlsx'
global recording_finished
if recording_finished_event.is_set(): if recording_finished_event.is_set():
recording_finished_event.clear() recording_finished_event.clear()
video_name = self.testcase_name_entry.get() video_name = self.testcase_name_entry.get()
length = int(self.video_length_entry.get()) # Hole die Länge des Videos
length = int(self.video_length_entry.get())
pulse = simpledialog.askinteger("Puls", "Bitte geben Sie Ihren Puls ein:") pulse = simpledialog.askinteger("Puls", "Bitte geben Sie Ihren Puls ein:")

if pulse is not None: if pulse is not None:
new_video_name = f"{video_name}_{length}_{pulse}.avi" new_video_name = f"{video_name}_{length}_{pulse}.avi"
original_video_path = os.path.join('videos', f"{video_name}.avi")
new_video_path = os.path.join('videos', new_video_name)
os.rename(original_video_path, new_video_path)
print(f"Video umbenannt zu {new_video_name}")
self.write_to_excel(new_video_name, excel_file_path)
original_video_path = os.path.join('code', 'videos', f"{video_name}.avi")
new_video_path = os.path.join('code', 'videos', new_video_name)

if not os.path.exists(original_video_path):
print(f"Datei nicht gefunden: {original_video_path}")
return

try:
os.rename(original_video_path, new_video_path)
print(f"Video umbenannt zu {new_video_name}")
self.write_to_excel(new_video_name, excel_file_path)
except Exception as e:
print(f"Fehler beim Umbenennen der Datei: {e}")
else: else:
print("recording_finished ist False, warte auf Aufnahmeende")
print("Kein Puls eingegeben.") print("Kein Puls eingegeben.")
# Planen Sie die nächste Überprüfung

self.after(100, self.check_recording_status) self.after(100, self.check_recording_status)


#ui relateted methods #ui relateted methods

+ 1
- 1
code/recording.py View File

""" """


output_folder = "videos"
output_folder = "code/videos"
output_file = os.path.join(output_folder, video_name + ".avi") output_file = os.path.join(output_folder, video_name + ".avi")
frame_rate = testcase_fps frame_rate = testcase_fps



BIN
code/testing/excel/Testcase_excel_dataset.xlsx View File


Loading…
Cancel
Save