Skip to content

Free Motion Capture for Everyone πŸ’€βœ¨

TypeScript

startup and initialization reorganization

aaroncheriandf9f3331126b
diff --git a/freemocap/fmc_runme.py b/freemocap/fmc_runme.py
index 8b10fb5d..0de524b5 100644
--- a/freemocap/fmc_runme.py
+++ b/freemocap/fmc_runme.py
@@ -2,7 +2,6 @@ from freemocap import (
createvideo,
recordingconfig,
runcams,
- runmeGUI,
calibrate,
fmc_mediapipe,
fmc_openpose,
@@ -11,11 +10,13 @@ from freemocap import (
playskeleton,
play_skeleton_animation,
session,
- webcamGUI
)
from freemocap.fmc_pyqtgraph import PlayerDockedWindow
+from freemocap.fmc_startup import startup
+from freemocap.webcam import camera_settings, timesync
+
from pathlib import Path
import os
@@ -57,106 +58,22 @@ def RunMe(sessionID=None,
sesh.userDataPath = userDataPath
sesh.dataFolderName = recordingconfig.dataFolder
- if sesh.useDLC and stage < 5:
- import deeplabcut as dlc
- # sesh.dlcConfigPath = dlcConfigPath
-
-
-
- #%% load user preferences if they exist, create a new preferences yaml if they don't
- here = Path(__file__).parent
- preferences_path = here/'user_preferences.yaml'
- preferences_yaml = YAML()
-
- if preferences_path.exists():
- preferences = preferences_yaml.load(preferences_path)
- else:
- preferences = recordingconfig.parameters_for_yaml
- preferences_yaml.dump(preferences, preferences_path)
-
- sesh.preferences = preferences
- sesh.preferences_path = preferences_path
-
+ # %% Startup
+ startup.get_user_preferences(sesh,stage)
- if sesh.useDLC and stage < 5:
+ if sesh.useDLC and stage<5:
+ import deeplabcut as dlc
+ dlc_config_paths = startup.get_dlc_paths(session)
- 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")
if stage > 1:
- #if we are rerunning a session folder
- # 1) Check if we're using the last saved dataFolderPath, or if the user wants to choose a different one
- # a. if the user wants to choose one, bring up a GUI to let them decide
- # b. if we're using the last known path - parse the user preferences yaml (and check if that yaml exists)
- # 2) Check that the data folder exists
- # 3) If no sessionID was user-input, search the chosen directory for the last session created
- if sesh.setDataPath == True:
- sesh.basePath = runmeGUI.RunChooseDataPathGUI(session)
- sesh.basePath = Path(sesh.basePath)
- #sesh.dataFolderPath = Path(basePath)/sesh.dataFolderName
-
- elif sesh.userDataPath is not None:
- sesh.basePath = sesh.userDataPath
- else:
- try:
- current_path_to_data = preferences['saved']['path_to_save']
- sesh.basePath = current_path_to_data
- except KeyError:
- print('Saved Data path not found, please choose a new one')
- sesh.basePath = runmeGUI.RunChooseDataPathGUI(session)
- sesh.preferences['saved']['path_to_save'] = str(sesh.basePath)
- sesh.save_user_preferences(sesh.preferences)
-
-
- dataFolder = Path(sesh.basePath)/sesh.dataFolderName
- sesh.dataFolderPath = dataFolder
-
- if not dataFolder.exists():
- raise FileNotFoundError('No data folder located at: ' + str(dataFolder))
-
+ startup.get_data_folder_path(sesh)
+
if sesh.sessionID == None:
subfolders = [f.path for f in os.scandir(sesh.dataFolderPath) if f.is_dir()] # copy-pasta from who knows where
sesh.sessionID = Path(subfolders[-1]).stem # grab the name of the last folder in the list of subfolders
print('Running ' + str(sesh.sessionID) + ' from ' + str(sesh.dataFolderPath))
-
- # if sesh. setDataPath == True:
- # #run file dialog GUI (select folder where the data folder)
- # here = Path(__file__).parent
- # parameter_path = here/'user_preferences.yaml'
- # if parameter_path.exists():
- # #this section looks for the Data folder at the last saved path from the user_preferences.yaml, if none exists, it raises an error
- # #if not, if finds the most recent session from that Data folder
- # parameters_yaml = YAML()
- # parameters = parameters_yaml.load(parameter_path)
- # current_path_to_data = parameters['saved']['path_to_save']
- # dataFolder = Path(current_path_to_data)/'Data'
- # try:
- # subfolders = [f.path for f in os.scandir(dataFolder) if f.is_dir()] # copy-pasta from who knows where
- # sesh.sessionID = Path(subfolders[-1]).stem # grab the name of the last folder in the list of subfolders
- # except FileNotFoundError:
- # raise FileNotFoundError('No data folder located at: ' + str(dataFolder))
-
- # print('Running ' + str(sesh.sessionID) + ' from ' + str(dataFolder))
- # sesh.dataPath = dataFolder
-
-
-
- #else: #First time run! Make 'FreeMoCap_Data' Folder (and eventually, prompt to download sample data)
- # dataFolder.mkdir()
- # sampleDataFolder = dataFolder / '_sample_data_folder'
- # sampleDataFolder.mkdir()
+
board = CharucoBoard(7, 5,
#square_length=1, # here, in mm but any unit works (JSM NOTE - just using '1' so resulting units will be in 'charuco squarelenghts`)
@@ -166,17 +83,13 @@ def RunMe(sessionID=None,
square_length = charucoSquareSize,#mm
marker_length = charucoSquareSize*.8,#mm
marker_bits=4, dict_size=250)
-
-
sesh.board = board
- #sesh.input_stage = stage
-
-
# %% Initialization
- #sesh.initialize(stage)
- if stage ==2 or stage == 1:
- webcamGUI.initialize(sesh,stage,board)
+ if stage == 1:
+ camera_settings.initialize(sesh,stage,board)
+ elif stage ==2:
+ timesync.time_sync_initialize(sesh)
else:
sesh.initialize(stage)
diff --git a/freemocap/fmc_startup/__init__.py b/freemocap/fmc_startup/__init__.py
new file mode 100644
index 00000000..9059c793
--- /dev/null
+++ b/freemocap/fmc_startup/__init__.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Mon Mar 1 13:39:34 2021
+
+@author: Rontc
+"""
diff --git a/freemocap/fmc_startup/startup.py b/freemocap/fmc_startup/startup.py
new file mode 100644
index 00000000..06fd5f44
--- /dev/null
+++ b/freemocap/fmc_startup/startup.py
@@ -0,0 +1,70 @@
+from pathlib import Path
+
+from ruamel.yaml import YAML
+
+from freemocap import recordingconfig
+from freemocap.fmc_startup import startupGUI
+
+def get_user_preferences(session,stage):
+ """
+ load user preferences if they exist, create a new preferences yaml if they don't
+ """
+ here = Path(__file__).parent
+ preferences_path = here/'user_preferences.yaml'
+ preferences_yaml = YAML()
+
+ #check for a user preferences yaml, if it doesn't exist, build one using the default parameters in recordingconfig.py
+ if preferences_path.exists():
+ preferences = preferences_yaml.load(preferences_path)
+ else:
+ preferences = recordingconfig.parameters_for_yaml
+ preferences_yaml.dump(preferences, preferences_path)
+
+ session.preferences = preferences
+ session.preferences_path = preferences_path
+
+def get_dlc_paths(session):
+ try:
+ saved_dlc_paths = session.preferences['saved']['dlc_config_paths']
+ except:
+ saved_dlc_paths = session.preferences['default']['dlc_config_paths']
+
+ dlc_config_paths = startupGUI.RunChooseDLCPathGUI(session,saved_dlc_paths)
+
+ session.preferences['saved']['dlc_config_paths'] = dlc_config_paths
+ session.save_user_preferences(session.preferences)
+ return dlc_config_paths
+
+def get_data_folder_path(session):
+ #if we are rerunning a session folder
+ # 1) Check if we're using the last saved dataFolderPath, or if the user wants to choose a different one
+ # a. if the user wants to choose one, bring up a GUI to let them decide
+ # b. if we're using the last known path - parse the user preferences yaml (and check if that yaml exists)
+ # 2) Check that the data folder exists
+ # 3) If no sessionID was user-input, search the chosen directory for the last session created
+ if session.setDataPath == True:
+ session.basePath = startupGUI.RunChooseDataPathGUI(session)
+ session.basePath = Path(session.basePath)
+ #sesh.dataFolderPath = Path(basePath)/sesh.dataFolderName
+
+ elif session.userDataPath is not None:
+ session.basePath = session.userDataPath
+
+ else:
+ try:
+ current_path_to_data = session.preferences['saved']['path_to_save']
+ session.basePath = current_path_to_data
+ except KeyError:
+ print('Saved Data path not found, please choose a new one')
+ session.basePath = startupGUI.RunChooseDataPathGUI(session)
+ session.preferences['saved']['path_to_save'] = str(session.basePath)
+ session.save_user_preferences(session.preferences)
+
+
+ dataFolder = Path(session.basePath)/session.dataFolderName
+ session.dataFolderPath = dataFolder
+
+ if not dataFolder.exists():
+ raise FileNotFoundError('No data folder located at: ' + str(dataFolder))
+
+
diff --git a/freemocap/runmeGUI.py b/freemocap/fmc_startup/startupGUI.py
similarity index 100%
rename from freemocap/runmeGUI.py
rename to freemocap/fmc_startup/startupGUI.py
diff --git a/freemocap/user_preferences.yaml b/freemocap/fmc_startup/user_preferences.yaml
similarity index 58%
rename from freemocap/user_preferences.yaml
rename to freemocap/fmc_startup/user_preferences.yaml
index 0b348102..3161f35f 100644
--- a/freemocap/user_preferences.yaml
+++ b/freemocap/fmc_startup/user_preferences.yaml
@@ -1,5 +1,5 @@
default:
- path_to_save: C:\Users\jonma\Dropbox\GitKrakenRepos\freemocap
+ path_to_save: C:\Users\aaron\Documents\GitHub\freemocap
dlc_config_paths: []
rotations: {}
parameters:
@@ -9,16 +9,13 @@ default:
framerate: 25
codec: DIVX
saved:
- path_to_save: C:/Users/jonma/Dropbox/FreeMoCapProject
+ path_to_save: C:\Users\aaron\Documents\GitHub\freemocap
rotations:
0: 0
1: 0
- 2: 0
- 3: 0
- 4: 0
parameters:
- exposure: -7
+ exposure: -5
resWidth: 640
resHeight: 480
- framerate: 30
+ framerate: 25
codec: DIVX
diff --git a/freemocap/session.py b/freemocap/session.py
index 5bf60b81..4d6128fb 100644
--- a/freemocap/session.py
+++ b/freemocap/session.py
@@ -2,6 +2,7 @@ from pathlib import Path
from ruamel.yaml import YAML
from freemocap import recordingconfig
+from freemocap.webcam import timesync
class Session: #self like "recording self"
def __init__(self):
diff --git a/freemocap/webcam/camera_settings.py b/freemocap/webcam/camera_settings.py
new file mode 100644
index 00000000..19063995
--- /dev/null
+++ b/freemocap/webcam/camera_settings.py
@@ -0,0 +1,125 @@
+from pathlib import Path
+from ruamel.yaml import YAML
+import datetime
+import sys
+import pandas as pd
+import numpy as np
+
+from freemocap.webcam import recordGUI, camsetup
+from freemocap import recordingconfig, fmc_anipose
+
+
+def initialize(session, stage, board):
+ """
+ Runs the initialization needed to start a new recording from scratch (Stage 1)
+ Create a new sessionID and attempt to load previous recording parameters (camera settings/rotations/save locations),
+ and use default values if previous parameters are not found. Ask user to select preferences using a series of GUIs, runs the Setup option if
+ chosen by the user, and ultimately sets a bool that dictates whether we should proceed to start the actual Stage 1 recording. Also saves parameters
+ into the session class, which gets saved into the user_preferences yaml
+
+ """
+
+ print("Starting initialization for stage {}".format(stage))
+ # if stage == 1:
+ filepath = Path.cwd()
+
+ session.board = board
+
+ # %% Stage One Initialization
+
+
+ # create session ID
+ sessionID_in = datetime.datetime.now().strftime("sesh_%Y-%m-%d_%H_%M_%S")
+ session.sessionID = sessionID_in
+
+#load the parameters YAML and extract the saved parameters if possible, and the default otherwise
+ #here = Path(__file__).parent
+ # parameter_path = here/'user_preferences.yaml'
+ # parameters_yaml = YAML()
+ # if parameter_path.exists():
+ # parameters = parameters_yaml.load(parameter_path)
+ # else:
+ # parameters = recordingconfig.parameters_for_yaml
+ # with open(parameter_path,'w') as outfile:
+ # parameters_yaml.dump(parameters, outfile)
+
+
+
+
+ proceedToRecording = False #create this boolean, set it to false, and if the user wants to record
+ #later in the pipeline, it will be set to true
+
+#run the GUI to get the tasks, the cams chosen, the camera settings, and the session ID
+ cam_inputs, task = recordGUI.RunChoiceGUI()
+ restartSetup = True
+
+ while restartSetup == True:
+
+ try:
+ rotation_entry = session.preferences["saved"]["rotations"]
+ parameter_entry = session.preferences["saved"]["parameters"]
+ except:
+ print("Could not load saved parameters, using default parameters")
+ rotation_entry = session.preferences['default']['rotations']
+ parameter_entry = session.preferences['default']['parameters']
+
+
+ try:
+ current_path_to_save = session.preferences['saved']['path_to_save']
+ except:
+ current_path_to_save = session.preferences['default']['path_to_save']
+ rotDict, paramDict, session.sessionID,savepath = recordGUI.RunParametersGUI(sessionID_in, rotation_entry, parameter_entry, current_path_to_save, cam_inputs, task)
+
+ #update the saved parameters in the YAML
+ #recordingconfig.rotation_settings['saved'] = rotDict
+ #recordingconfig.camera_session.preferences['saved'] = paramDict
+ session.preferences['saved']['rotations'] = rotDict
+ session.preferences['saved']['parameters'] = paramDict
+ if savepath is not None:
+ session.preferences['saved']['path_to_save'] = savepath
+
+ session.save_user_preferences(session.preferences)
+
+ #save recording parameters to the config yaml
+
+
+ #create a list from the rotation dictionary to be used in running webcams
+ rotation_input = list(rotDict.values())
+
+ if task == "setup":
+ # run setup processes, and then check if th user wants to proceed to recording
+ camsetup.RunSetup(cam_inputs, rotation_input, paramDict)
+ proceedToRecording, restartSetup, session.sessionID, savepath = recordGUI.RunProceedtoRecordGUI(
+ sessionID_in,current_path_to_save
+ )
+ session.preferences['saved']['path_to_save'] = savepath
+ session.save_user_preferences(session.preferences)
+ elif task == "record":
+ proceedToRecording = True
+ restartSetup = False
+
+ if proceedToRecording:
+ # create these session properties to be used later in the pipeline
+ session.cam_inputs = cam_inputs
+ session.parameterDictionary = paramDict
+ session.rotationInputs = rotation_input
+ session.basePath = Path(savepath)
+
+ #create a config yaml and text file for this session
+ session.start_session(session.parameterDictionary,session.rotationInputs)
+ session.session_settings['recording_parameters']['RotationInputs'] = rotDict
+ session.session_settings['recording_parameters']['ParameterDict'] = paramDict
+ #configyaml = YAML()
+ #sessionsettings = configyaml.load(session.session_yaml_path)
+ #sessionsettings['recording_parameters']['RotationInputs'] = rotDict
+ #sessionsettings['recording_parameters']['ParameterDict'] = paramDict
+ #configyaml.dump(sessionsettings, session.session_yaml_path)
+ #print(sessionsettings)
+ #config_yaml_path = recordingconfig.createSession(session,filepath)
+ #recordingconfig.createSessionTxt(session,paramDict,rotDict)
+
+ print('Proceeding to Stage One')
+
+ else:
+
+ sys.exit('Recording Canceled')
diff --git a/freemocap/webcam/timesync.py b/freemocap/webcam/timesync.py
index cca2b439..495e42a4 100644
--- a/freemocap/webcam/timesync.py
+++ b/freemocap/webcam/timesync.py
@@ -235,3 +235,42 @@ class proceedGUI:
def destroy(self):
self.proceed = True
self.master.destroy()
+
+
+
+
+def time_sync_initialize(session):
+ """
+ Initialize settings specific to the time syncing stage if running stage 2
+ """
+ #from the config settings add the camera input parameters to parameter dictionary
+ session.initialize(stage = 2)
+ session.parameterDictionary = session.session_settings['recording_parameters']['ParameterDict']
+ rotationDict = session.session_settings['recording_parameters']['RotationInputs']
+ session.rotationInputs = list(rotationDict.values())
+ #initialize the path to the timestamp csv
+ csvName = session.sessionID + '_timestamps.csv'
+ csvPath = session.rawVidPath/csvName
+
+ #read CSV data, turn it into a data frame
+ timeStampData = pd.read_csv (csvPath)
+ timeStampData = timeStampData.iloc[:,1:]
+
+ #get the camIDs and number of cameras (numCamRange) from the dataframe
+ camIDs = list(timeStampData.columns)
+ numCams = len(camIDs)
+ numCamRange = range(len(camIDs))
+
+ #create names for each of the raw videos
+ vidNames = []
+ for x in numCamRange:
+ singleVidName = 'raw_cam{}.mp4'.format(x+1)
+ vidNames.append(singleVidName)
+
+
+ #initialize all the session variables we'll need to run the rest of the pipeline
+ session.timeStampData = timeStampData
+ session.camIDs = camIDs
+ session.numCamRange = numCamRange
+ session.vidNames = vidNames
+ session.numCams = numCams
diff --git a/freemocap/webcamGUI.py b/freemocap/webcamGUI.py
deleted file mode 100644
index 72ddad65..00000000
--- a/freemocap/webcamGUI.py
+++ /dev/null
@@ -1,294 +0,0 @@
-from pathlib import Path
-from ruamel.yaml import YAML
-import datetime
-import sys
-import pandas as pd
-import numpy as np
-
-from freemocap.webcam import recordGUI, camsetup
-from freemocap import recordingconfig, fmc_anipose
-
-
-def initialize(session, stage, board):
- """
- Runs the initialization needed to either a) start a new recording from scratch (Stage 1), or b) continue a sesssion from stage 2 (time-syncing).
-
- If running from stage 1: create a new sessionID and attempt to load previous recording parameters (camera settings/rotations/save locations),
- and use default values if previous parameters are not found. Ask user to select preferences using a series of GUIs, runs the Setup option if
- chosen by the user, and ultimately sets a bool that dictates whether we should proceed to start the actual Stage 1 recording. Also saves parameters
- into the session class, which gets saved into the user_preferences yaml
-
- If running from stage 2: loads the timestamps and reads them into a dataframe, and sets up all the parameters necesary to run the pipeline
- """
-
- print("Starting initialization for stage {}".format(stage))
- # if stage == 1:
- filepath = Path.cwd()
-
- session.board = board
-
- # %% Stage One Initialization
- if stage == 1:
-
- # create session ID
- sessionID_in = datetime.datetime.now().strftime("sesh_%Y-%m-%d_%H_%M_%S")
- session.sessionID = sessionID_in
-
- #load the parameters YAML and extract the saved parameters if possible, and the default otherwise
- #here = Path(__file__).parent
- # parameter_path = here/'user_preferences.yaml'
- # parameters_yaml = YAML()
- # if parameter_path.exists():
- # parameters = parameters_yaml.load(parameter_path)
- # else:
- # parameters = recordingconfig.parameters_for_yaml
- # with open(parameter_path,'w') as outfile:
- # parameters_yaml.dump(parameters, outfile)
-
-
-
-
- proceedToRecording = False #create this boolean, set it to false, and if the user wants to record
- #later in the pipeline, it will be set to true
-
- #run the GUI to get the tasks, the cams chosen, the camera settings, and the session ID
- cam_inputs, task = recordGUI.RunChoiceGUI()
- restartSetup = True
-
- while restartSetup == True:
-
- try:
- rotation_entry = session.preferences["saved"]["rotations"]
- parameter_entry = session.preferences["saved"]["parameters"]
- except:
- print("Could not load saved parameters, using default parameters")
- rotation_entry = session.preferences['default']['rotations']
- parameter_entry = session.preferences['default']['parameters']
-
-
- try:
- current_path_to_save = session.preferences['saved']['path_to_save']
- except:
- current_path_to_save = session.preferences['default']['path_to_save']
- rotDict, paramDict, session.sessionID,savepath = recordGUI.RunParametersGUI(sessionID_in, rotation_entry, parameter_entry, current_path_to_save, cam_inputs, task)
-
- #update the saved parameters in the YAML
- #recordingconfig.rotation_settings['saved'] = rotDict
- #recordingconfig.camera_session.preferences['saved'] = paramDict
- session.preferences['saved']['rotations'] = rotDict
- session.preferences['saved']['parameters'] = paramDict
- if savepath is not None:
- session.preferences['saved']['path_to_save'] = savepath
-
- session.save_user_preferences(session.preferences)
-
- #save recording parameters to the config yaml
-
-
- #create a list from the rotation dictionary to be used in running webcams
- rotation_input = list(rotDict.values())
-
- if task == "setup":
- # run setup processes, and then check if th user wants to proceed to recording
- camsetup.RunSetup(cam_inputs, rotation_input, paramDict)
- proceedToRecording, restartSetup, session.sessionID, savepath = recordGUI.RunProceedtoRecordGUI(
- sessionID_in,current_path_to_save
- )
- session.preferences['saved']['path_to_save'] = savepath
- session.save_user_preferences(session.preferences)
- elif task == "record":
- proceedToRecording = True
- restartSetup = False
-
- if proceedToRecording:
- # create these session properties to be used later in the pipeline
- session.cam_inputs = cam_inputs
- session.parameterDictionary = paramDict
- session.rotationInputs = rotation_input
- session.basePath = Path(savepath)
-
- #create a config yaml and text file for this session
- session.start_session(session.parameterDictionary,session.rotationInputs)
- session.session_settings['recording_parameters']['RotationInputs'] = rotDict
- session.session_settings['recording_parameters']['ParameterDict'] = paramDict
- #configyaml = YAML()
- #sessionsettings = configyaml.load(session.session_yaml_path)
- #sessionsettings['recording_parameters']['RotationInputs'] = rotDict
- #sessionsettings['recording_parameters']['ParameterDict'] = paramDict
- #configyaml.dump(sessionsettings, session.session_yaml_path)
- #print(sessionsettings)
- #config_yaml_path = recordingconfig.createSession(session,filepath)
- #recordingconfig.createSessionTxt(session,paramDict,rotDict)
-
- print('Proceeding to Stage One')
-
- else:
-
- sys.exit('Recording Canceled')
-# %% Stage Two Initalization
- if stage == 2:
- # session.sessionPath = filepath/'Data'/session.sessionID #create a session path based on the sessionID
-
- # #load the config yaml for this session, and add all the paths to the session file
- # session.yamlPath = session.sessionPath/'{}_config.yaml'.format(session.sessionID)
- # session.config_settings = recordingconfig.load_config_yaml(session.yamlPath) #config settings = paths and camera parameter inputs
- # recordingconfig.load_session_paths(session,session.config_settings) #add paths to session class
- session.initialize(stage)
-
- #from the config settings add the camera input parameters to parameter dictionary
- session.parameterDictionary = session.session_settings['recording_parameters']['ParameterDict']
- rotationDict = session.session_settings['recording_parameters']['RotationInputs']
- session.rotationInputs = list(rotationDict.values())
- #initialize the path to the timestamp csv
- csvName = session.sessionID + '_timestamps.csv'
- csvPath = session.rawVidPath/csvName
-
- #read CSV data, turn it into a data frame
- timeStampData = pd.read_csv (csvPath)
- timeStampData = timeStampData.iloc[:,1:]
-
- #get the camIDs and number of cameras (numCamRange) from the dataframe
- camIDs = list(timeStampData.columns)
- numCams = len(camIDs)
- numCamRange = range(len(camIDs))
-
- #create names for each of the raw videos
- vidNames = []
- for x in numCamRange:
- singleVidName = 'raw_cam{}.mp4'.format(x+1)
- vidNames.append(singleVidName)
-
-
- #initialize all the session variables we'll need to run the rest of the pipeline
- session.timeStampData = timeStampData
- session.camIDs = camIDs
- session.numCamRange = numCamRange
- session.vidNames = vidNames
- session.numCams = numCams
-
-# if stage == 3:
-
-# session.sessionPath = (
-# filepath / "Data" / session.sessionID
-# ) # create a session path based on the sessionID
-
-# # load the config yaml for this session, and add all the paths to the session file
-# session.yamlPath = session.sessionPath / "{}_config.yaml".format(
-# session.sessionID
-# )
-
-# if (
-# session.yamlPath.is_file()
-# ): # if the config yaml exists (from a webcam recording)
-# session.config_settings = recordingconfig.load_config_yaml(
-# session.yamlPath
-# ) # config settings = paths and camera parameter inputs
-# recordingconfig.load_session_paths(
-# session, session.config_settings
-# ) # add paths to session class
-# else: # if it doesn't exist (because of a GoPro/external camera recording)
-# recordingconfig.createSession(session, filepath)
-
-# if stage == 4:
-
-# session.sessionPath = filepath / "Data" / session.sessionID
-
-# session.yamlPath = session.sessionPath / "{}_config.yaml".format(
-# session.sessionID
-# ) # path to the configuration yaml
-# session.config_settings = recordingconfig.load_config_yaml(
-# session.yamlPath
-# ) # config settings = paths and camera parameter inputs
-# recordingconfig.load_session_paths(
-# session, session.config_settings
-# ) # add paths to session class
-
-# for count, thisVidPath in enumerate(
-# session.syncedVidPath.glob("*.mp4"), start=1
-# ):
-# session.numCams = count
-
-# if stage == 6:
-
-# session.sessionPath = filepath / "Data" / session.sessionID
-
-# session.yamlPath = session.sessionPath / "{}_config.yaml".format(
-# session.sessionID
-# ) # path to the configuration yaml
-# session.config_settings = recordingconfig.load_config_yaml(
-# session.yamlPath
-# ) # config settings = paths and camera parameter inputs
-# recordingconfig.load_session_paths(
-# session, session.config_settings
-# ) # add paths to session class
-
-# if session.useOpenPose:
-# session.openPose_imgPathList = session.config_settings[
-# "openPose_imgPathList"
-# ]
-
-# if session.useMediaPipe:
-# session.mediaPipe_imgPathList = session.config_settings[
-# "mediaPipe_imgPathList"
-# ]
-
-# # if stage == 5:
-
-# # session.sessionPath = filepath/'Data'/session.sessionID
-
-# # session.yamlPath = session.sessionPath/'{}_config.yaml'.format(session.sessionID) #path to the configuration yaml
-# # session.config_settings = recordingconfig.load_config_yaml(session.yamlPath) #config settings = paths and camera parameter inputs
-# # recordingconfig.load_session_paths(session,session.config_settings) #add paths to session class
-
-# # for count,thisVidPath in enumerate(session.syncedVidPath.glob('*.mp4'),start=1):
-# # session.numCams = count
-
-# # session.mediaPipe_jsonPathList = session.config_settings['mediaPipe_jsonPathList']
-# # session.numCams = len(session.mediaPipe_jsonPathList)
-
-# # if stage == 6:
-
-# # session.sessionPath = filepath/'Data'/session.sessionID
-
-# # session.yamlPath = session.sessionPath/'{}_config.yaml'.format(session.sessionID) #path to the configuration yaml
-# # session.config_settings = recordingconfig.load_config_yaml(session.yamlPath) #config settings = paths and camera parameter inputs
-# # recordingconfig.load_session_paths(session,session.config_settings) #add paths to session class
-
-# # session.mediaPipeData_nCams_nFrames_nImgPts_XY = np.load(session.dataArrayPath/'mediaPipeData_nCams_nFrames_nImgPts_XY.npy')
-
-# if stage == 7:
-
-# session.sessionPath = filepath / "Data" / session.sessionID
-
-# session.yamlPath = session.sessionPath / "{}_config.yaml".format(
-# session.sessionID
-# ) # path to the configuration yaml
-# session.config_settings = recordingconfig.load_config_yaml(
-# session.yamlPath
-# ) # config settings = paths and camera parameter inputs
-# recordingconfig.load_session_paths(
-# session, session.config_settings
-# ) # add paths to session class
-
-# session.mediaPipe_imgPathList = session.config_settings["mediaPipe_imgPathList"]
-# session.openPose_imgPathList = session.config_settings["openPose_imgPathList"]
-
-# # session.openPose_imgPathList = session.config_settings['openPose_imgPathList']
-# # session.numCams = len(session.openPose_imgPathList)
-
-# if stage == 8:
-
-# session.sessionPath = filepath / "Data" / session.sessionID
-
-# session.yamlPath = session.sessionPath / "{}_config.yaml".format(
-# session.sessionID
-# ) # path to the configuration yaml
-# session.config_settings = recordingconfig.load_config_yaml(
-# session.yamlPath
-# ) # config settings = paths and camera parameter inputs
-# recordingconfig.load_session_paths(
-# session, session.config_settings
-# ) # add paths to session class
-
-
-# # %%
diff --git a/runme_FreeMoCap.py b/runme_FreeMoCap.py
index 2b051299..5facfe25 100644
--- a/runme_FreeMoCap.py
+++ b/runme_FreeMoCap.py
@@ -1,3 +1,3 @@
import freemocap as fmc
-fmc.RunMe(useOpenPose = False, useMediaPipe=True)
\ No newline at end of file
+fmc.RunMe(useOpenPose = False, useMediaPipe=True, stage = 1)
\ No newline at end of file