Browse Source

Last finishes

master
Erik Hildebrandt 2 years ago
parent
commit
fab12d3f54
  1. 7
      DataStreamModule.py
  2. 1
      HPEModule.py
  3. 7
      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
def get_camera_stream(self, camera_name):
cap = cv2.VideoCapture(camera_name)
total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
current_frame = 0
while cap.isOpened():
ret, frame = cap.read()
# Yield each frame as a numpy array
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()

1
HPEModule.py

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

7
PoseEstimationGUI.py

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

5
main.py

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

Loading…
Cancel
Save