Free Motion Capture for Everyone πβ¨
TypeScript
DLC config path GUI added
Aaron Cherian3bc8ed4ad4aa
diff --git a/freemocap/fmc_runme.py b/freemocap/fmc_runme.pyindex 08e60dac..3c33460b 100644--- a/freemocap/fmc_runme.py+++ b/freemocap/fmc_runme.py@@ -37,7 +37,7 @@ def Run(sessionID=None,stage=1,useOpenPose=True,useMediaPipe=False,useDLC=True,dif sesh.useDLC:import deeplabcut as dlc- sesh.dlcConfigPath = dlcConfigPath+ # sesh.dlcConfigPath = dlcConfigPath#%% load user preferences if they exist, create a new preferences yaml if they don't@@ -54,7 +54,18 @@ def Run(sessionID=None,stage=1,useOpenPose=True,useMediaPipe=False,useDLC=True,dsesh.preferences = preferencessesh.preferences_path = preferences_path- #if sesh.useDLC:+ if sesh.useDLC:+ try:+ saved_dlc_paths = preferences['saved']['dlc_config_paths']+ except:+ saved_dlc_paths = preferences['default']['dlc_config_paths']+++ dlc_config_paths = runmeGUI.RunChooseDLCPathGUI(sesh,saved_dlc_paths)+++ sesh.preferences['saved']['dlc_config_paths'] = dlc_config_paths+ sesh.save_user_preferences(sesh.preferences)# sesh.dlcConfigPath = Path("C:\\Users\\jonma\\Dropbox\\GitKrakenRepos\\freemocap\\DLC_Models\\PinkGreenRedJugglingBalls-JSM-2021-05-31\\config.yaml")#sesh.dlcConfigPath = Path("C:\\Users\\jonma\\Desktop\\freemocap\\DLC_Models\\PinkGreenRedJugglingBalls-JSM-2021-05-31\\config.yaml")@@ -179,7 +190,8 @@ def Run(sessionID=None,stage=1,useOpenPose=True,useMediaPipe=False,useDLC=True,dfor vid in sesh.syncedVidPath.glob('*.mp4'):sesh.syncedVidList.append(str(vid))- dlc.analyze_videos(sesh.dlcConfigPath,sesh.syncedVidList, destfolder= sesh.dlcDataPath, save_as_csv=True)+ for config_path in dlc_config_paths:+ dlc.analyze_videos(sesh.dlcConfigPath,sesh.syncedVidList, destfolder= sesh.dlcDataPath, save_as_csv=True)sesh.dlcData_nCams_nFrames_nImgPts_XYC = fmc_deeplabcut.parseDeepLabCut(sesh)sesh.dlc_fr_mar_dim = reconstruct3D.reconstruct3D(sesh,sesh.dlcData_nCams_nFrames_nImgPts_XYC, confidenceThreshold=.95)diff --git a/freemocap/recordingconfig.py b/freemocap/recordingconfig.pyindex 9cb527f3..ead7102b 100644--- a/freemocap/recordingconfig.py+++ b/freemocap/recordingconfig.py@@ -9,7 +9,7 @@ from pathlib import Pathfolder_setup = ['RawVideos','SyncedVideos','CalVideos','DataArrays','DLCData','OpenPoseData','MediaPipeData','imOut']-default_parameters = {'path_to_save': str(Path.cwd()),'dlcconfig_paths':[], 'rotations':{},'parameters':{'exposure':-5,'resWidth':640,'resHeight':480,'framerate':25,'codec':'DIVX'}}+default_parameters = {'path_to_save': str(Path.cwd()),'dlc_config_paths':[], 'rotations':{},'parameters':{'exposure':-5,'resWidth':640,'resHeight':480,'framerate':25,'codec':'DIVX'}}saved_parameters = default_parametersparameters_for_yaml = {'default':default_parameters,'saved':{}}diff --git a/freemocap/runmeGUI.py b/freemocap/runmeGUI.pyindex 508dad38..959d3221 100644--- a/freemocap/runmeGUI.py+++ b/freemocap/runmeGUI.py@@ -2,6 +2,8 @@ import tkinter as tkfrom tkinter import Tk, Label, Button, Frame, Listbox, Entry, filedialogfrom pathlib import Path+from numpy.lib.npyio import save+class setDataPathGUI:def __init__(self, master,session):self.master = master@@ -46,10 +48,58 @@ class setDataPathGUI:class DLCConfigPathGUI:- def __init__(self):-+ def __init__(self,master,session,saved_dlc_paths):+ #saved_dlc_paths = ['one','two','three']+ self.master = master+ self.dlc_paths = saved_dlc_paths.copy()+ self.session = session++ introText = "Here are your currently saved DLC config paths"+ introLabel = Label(master, text=introText)+ introLabel.pack(side="top")++ #savedPathText = self.write_to_string(saved_dlc_paths)+ self.savedPathVar = tk.StringVar()+ #savedPathVar.set(savedPathText)+ self.update_dlc_path_label(self.dlc_paths)+ savedPathLabel = Label(master,textvariable=self.savedPathVar)+ savedPathLabel.pack()++ addpath_button = Button(master,text = 'Add a file path',command = self.openFileDialog)+ addpath_button.pack(side='top')++ clearpath_button = Button(master,text = 'Clear file paths',command = self.clearPaths)+ clearpath_button.pack(side='top')- pass+ savepath_button = Button(master,text = 'Save file paths and Proceed',command = self.savePaths)+ savepath_button.pack(side = 'top')+++ def update_dlc_path_label(self,saved_dlc_paths):+ dlc_string_list = '\n'.join(saved_dlc_paths)+ self.savedPathVar.set(dlc_string_list)+ return dlc_string_list++ def openFileDialog(self):+ chosen_path = filedialog.askopenfilename(+ title='Open a file',+ initialdir= Path.cwd(),+ filetypes=[('Yaml','*.yaml')])+ self.dlc_paths.append(chosen_path)+ self.update_dlc_path_label(self.dlc_paths)+ f = 2++ def clearPaths(self):+ self.dlc_paths = []+ self.update_dlc_path_label(self.dlc_paths)++ def savePaths(self):+ self.config_paths= self.dlc_paths+ self.master.destroy()+++ f = 2+@@ -59,4 +109,16 @@ def RunChooseDataPathGUI(session):chosenDataPath = setDataPathGUI(root, session)root.mainloop()- return chosenDataPath.dataPath\ No newline at end of file+ return chosenDataPath.dataPath+++def RunChooseDLCPathGUI(session,saved_dlc_paths):+ root = tk.Tk()+ chosenDLCPaths = DLCConfigPathGUI(root,session,saved_dlc_paths)+ root.mainloop()++ return chosenDLCPaths.config_paths++ f = 2++\ No newline at end of filediff --git a/freemocap_test.py b/freemocap_test.pynew file mode 100644index 00000000..44eff2d1--- /dev/null+++ b/freemocap_test.py@@ -0,0 +1,14 @@+import freemocap++# sessionID = ''+# stage = 1+# useOpenPose = True+# useMediaPipe = False+# useDLC = False+# debug = False+++# freemocap.RunMe(sessionID,stage,useOpenPose,useMediaPipe,useDLC,debug)++freemocap.RunMe( stage = 1, useDLC=True,setDataPath=False)+