You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
3.3 KiB
75 lines
3.3 KiB
import tkinter as tk
|
|
from tkinter import filedialog
|
|
from tkinter import Label
|
|
from DataStreamModule import DataStreamModule
|
|
from HPEModule import HPEModule
|
|
import threading
|
|
|
|
|
|
class PoseEstimationGUI:
|
|
|
|
def __init__(self):
|
|
self.mp4_file_path = None
|
|
self.root = tk.Tk()
|
|
self.root.title("Pose Estimation GUI")
|
|
self.root.geometry("400x250")
|
|
self.root.config(bg="#F9F9F9")
|
|
|
|
self.camera_options = [] # Initialize camera options list
|
|
|
|
# Create a drop-down menu with available cameras
|
|
self.camera_options = DataStreamModule().findCameras()
|
|
self.selected_camera = tk.StringVar()
|
|
self.selected_camera.set(self.camera_options[0]) # default value
|
|
camera_label = tk.Label(self.root, text="Select a camera:", bg="#F9F9F9", font=("Arial", 12, "bold"))
|
|
camera_label.pack(pady=(20, 0))
|
|
camera_menu = tk.OptionMenu(self.root, self.selected_camera, *self.camera_options)
|
|
camera_menu.config(font=("Arial", 12))
|
|
camera_menu.pack()
|
|
|
|
# Create a button to select an mp4 file
|
|
self.select_file_button = tk.Button(self.root, text="Select MP4 File to Start HPE on", bg="#2196F3", fg="white",
|
|
font=("Arial", 12, "bold"), command=self.select_file)
|
|
self.select_file_button.pack(pady=(10, 20))
|
|
|
|
# Create label widget to indicate file selection status
|
|
self.file_selected_label = Label(self.root, text="No file selected", fg="red", bg="#F9F9F9",
|
|
font=("Arial", 12))
|
|
self.file_selected_label.pack(pady=(10, 0))
|
|
|
|
# Create a button to start pose estimation
|
|
self.start_button = tk.Button(self.root, text="Start Pose Estimation", bg="#4CAF50", fg="white",
|
|
font=("Arial", 12, "bold"), command=self.start_pose_estimation)
|
|
self.start_button.pack(pady=(20, 10))
|
|
|
|
self.root.mainloop()
|
|
|
|
def start_pose_estimation(self):
|
|
if self.mp4_file_path is not None:
|
|
# Start pose estimation on the selected mp4 file
|
|
pose_estimator = HPEModule()
|
|
pose_thread_file = threading.Thread(target=pose_estimator.startHPEwithCamera, args=(self.mp4_file_path,))
|
|
self.mp4_file_path = None
|
|
self.file_selected_label.config(text="No File selected", fg="red")
|
|
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,))
|
|
pose_thread_camera.start()
|
|
|
|
def select_file(self):
|
|
self.mp4_file_path = filedialog.askopenfilename(initialdir="/", title="Select MP4 File to Start HPE on",
|
|
filetypes=(("mp4 files", "*.mp4"), ("all files", "*.*")))
|
|
# Update file selection status label
|
|
if self.mp4_file_path:
|
|
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()
|
|
|