Browse Source

Last finishes

master
Erik Hildebrandt 2 years ago
parent
commit
fab12d3f54
  1. 7
      DataStreamModule.py
  2. 1
      HPEModule.py
  3. 5
      PoseEstimationGUI.py
  4. 5
      main.py

7
DataStreamModule.py

@ -26,15 +26,8 @@ class DataStreamModule(IDataStreamModule):
# Method to get the camera stream from a given camera # Method to get the camera stream from a given camera
def get_camera_stream(self, camera_name): def get_camera_stream(self, camera_name):
cap = cv2.VideoCapture(camera_name) cap = cv2.VideoCapture(camera_name)
total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
current_frame = 0
while cap.isOpened(): while cap.isOpened():
ret, frame = cap.read() ret, frame = cap.read()
# Yield each frame as a numpy array # Yield each frame as a numpy array
yield np.array(frame) yield np.array(frame)
current_frame += 1
if current_frame == total_frames - 1:
# If the current frame is the second-to-last frame, reset to the beginning of the file
cap.set(cv2.CAP_PROP_POS_FRAMES, 0)
current_frame = 0
cap.release() cap.release()

1
HPEModule.py

@ -1,6 +1,5 @@
import os import os
from xml.dom import minidom from xml.dom import minidom
import cv2 import cv2
import mediapipe as mp import mediapipe as mp
from DataStreamModule import DataStreamModule from DataStreamModule import DataStreamModule

5
PoseEstimationGUI.py

@ -62,7 +62,6 @@ class PoseEstimationGUI:
pose_thread_file.start() pose_thread_file.start()
else: else:
# Start pose estimation on the selected camera # Start pose estimation on the selected camera
# print(self.selected_camera.get())
pose_estimator = HPEModule() pose_estimator = HPEModule()
camera = int(self.selected_camera.get()) camera = int(self.selected_camera.get())
pose_thread_camera = threading.Thread(target=pose_estimator.startHPEwithCamera, args=(camera, self.export_Landmarks,)) pose_thread_camera = threading.Thread(target=pose_estimator.startHPEwithCamera, args=(camera, self.export_Landmarks,))
@ -77,7 +76,3 @@ class PoseEstimationGUI:
else: else:
self.file_selected_label.config(text="No File selected", fg="red") self.file_selected_label.config(text="No File selected", fg="red")
self.mp4_file_path = None self.mp4_file_path = None
if __name__ == '__main__':
PoseEstimationGUI()

5
main.py

@ -1,5 +1,4 @@
from HPEModule import HPEModule from PoseEstimationGUI import PoseEstimationGUI
if __name__ == '__main__': if __name__ == '__main__':
pe = HPEModule() # use camera 0 gui = PoseEstimationGUI() # use camera 0
pe.startHPEwithCamera(0)

Loading…
Cancel
Save