diff --git a/code/__pycache__/constants.cpython-310.pyc b/code/__pycache__/constants.cpython-310.pyc index 881ff68..b39098a 100644 Binary files a/code/__pycache__/constants.cpython-310.pyc and b/code/__pycache__/constants.cpython-310.pyc differ diff --git a/code/__pycache__/eulerian.cpython-310.pyc b/code/__pycache__/eulerian.cpython-310.pyc index ab8166a..9e10507 100644 Binary files a/code/__pycache__/eulerian.cpython-310.pyc and b/code/__pycache__/eulerian.cpython-310.pyc differ diff --git a/code/__pycache__/excel_processing.cpython-310.pyc b/code/__pycache__/excel_processing.cpython-310.pyc index 0ee3721..7f99a33 100644 Binary files a/code/__pycache__/excel_processing.cpython-310.pyc and b/code/__pycache__/excel_processing.cpython-310.pyc differ diff --git a/code/__pycache__/excel_update.cpython-310.pyc b/code/__pycache__/excel_update.cpython-310.pyc index 6b2edc5..aca38a9 100644 Binary files a/code/__pycache__/excel_update.cpython-310.pyc and b/code/__pycache__/excel_update.cpython-310.pyc differ diff --git a/code/__pycache__/facedetection.cpython-310.pyc b/code/__pycache__/facedetection.cpython-310.pyc index 187a785..0613cdf 100644 Binary files a/code/__pycache__/facedetection.cpython-310.pyc and b/code/__pycache__/facedetection.cpython-310.pyc differ diff --git a/code/__pycache__/heartrate.cpython-310.pyc b/code/__pycache__/heartrate.cpython-310.pyc index 00f31b7..5e2970b 100644 Binary files a/code/__pycache__/heartrate.cpython-310.pyc and b/code/__pycache__/heartrate.cpython-310.pyc differ diff --git a/code/__pycache__/processing.cpython-310.pyc b/code/__pycache__/processing.cpython-310.pyc index 5163ec1..e27af07 100644 Binary files a/code/__pycache__/processing.cpython-310.pyc and b/code/__pycache__/processing.cpython-310.pyc differ diff --git a/code/__pycache__/pyramids.cpython-310.pyc b/code/__pycache__/pyramids.cpython-310.pyc index 5afe855..6784b03 100644 Binary files a/code/__pycache__/pyramids.cpython-310.pyc and b/code/__pycache__/pyramids.cpython-310.pyc differ diff --git a/code/__pycache__/recording.cpython-310.pyc b/code/__pycache__/recording.cpython-310.pyc index ecc7f33..92083c1 100644 Binary files a/code/__pycache__/recording.cpython-310.pyc and b/code/__pycache__/recording.cpython-310.pyc differ diff --git a/code/facedetection2.py b/code/facedetection2.py new file mode 100644 index 0000000..2b81e50 --- /dev/null +++ b/code/facedetection2.py @@ -0,0 +1,61 @@ +""" +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 diff --git a/code/main.py b/code/main.py index e0075dc..29baee1 100644 --- a/code/main.py +++ b/code/main.py @@ -27,8 +27,8 @@ code_version= "1.0" 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): def __init__(self): @@ -186,27 +186,33 @@ class VideoProcessingApp(tk.Tk): 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(): - recording_finished_event.clear() 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:") + if pulse is not None: 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: - print("recording_finished ist False, warte auf Aufnahmeende") print("Kein Puls eingegeben.") - # Planen Sie die nächste Überprüfung - + self.after(100, self.check_recording_status) #ui relateted methods diff --git a/code/recording.py b/code/recording.py index 41a1254..9b73314 100644 --- a/code/recording.py +++ b/code/recording.py @@ -56,7 +56,7 @@ def record_video(video_name="aufgenommenes_video", length=5,testcase_resolution1 """ - output_folder = "videos" + output_folder = "code/videos" output_file = os.path.join(output_folder, video_name + ".avi") frame_rate = testcase_fps diff --git a/code/testing/excel/Testcase_excel_dataset.xlsx b/code/testing/excel/Testcase_excel_dataset.xlsx index 27161ce..1b20383 100644 Binary files a/code/testing/excel/Testcase_excel_dataset.xlsx and b/code/testing/excel/Testcase_excel_dataset.xlsx differ