test case record gefixxt und alte facedetect hinzugefügt
This commit is contained in:
parent
9dee7fc59a
commit
7704a34b1c
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
61
code/facedetection2.py
Normal file
61
code/facedetection2.py
Normal file
@ -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
|
36
code/main.py
36
code/main.py
@ -27,8 +27,8 @@ code_version= "1.0"
|
|||||||
|
|
||||||
|
|
||||||
current_dir = os.getcwd()
|
current_dir = os.getcwd()
|
||||||
testcase_excel_file_path = os.path.join(current_dir, 'testing/excel/Testcase_excel_dataset.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, 'testing/excel/Testruns.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):
|
||||||
@ -186,27 +186,33 @@ class VideoProcessingApp(tk.Tk):
|
|||||||
|
|
||||||
|
|
||||||
def check_recording_status(self):
|
def check_recording_status(self):
|
||||||
excel_file_path = 'testing/excel/Testcase_excel_dataset.xlsx'
|
excel_file_path = 'code/testing/excel/Testcase_excel_dataset.xlsx'
|
||||||
global recording_finished # Deklarieren Sie die Verwendung der globalen Variable
|
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")
|
original_video_path = os.path.join('code', 'videos', f"{video_name}.avi")
|
||||||
new_video_path = os.path.join('videos', new_video_name)
|
new_video_path = os.path.join('code', 'videos', new_video_name)
|
||||||
os.rename(original_video_path, new_video_path)
|
|
||||||
print(f"Video umbenannt zu {new_video_name}")
|
if not os.path.exists(original_video_path):
|
||||||
self.write_to_excel(new_video_name, excel_file_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
|
||||||
|
@ -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")
|
output_file = os.path.join(output_folder, video_name + ".avi")
|
||||||
frame_rate = testcase_fps
|
frame_rate = testcase_fps
|
||||||
|
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user