Skip to content

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

TypeScript

Split up webcamGUI initialization, Stage 3 fixes

Aaron Cherian2d876e4aead3
diff --git a/freemocap/calibrate.py b/freemocap/calibrate.py
index 528b83d3..d3515444 100644
--- a/freemocap/calibrate.py
+++ b/freemocap/calibrate.py
@@ -13,6 +13,9 @@ from rich.progress import track
def CalibrateCaptureVolume(session,board):
+ session.calVidPath.mkdir(exist_ok = True)
+ session.dataArrayPath.mkdir(exist_ok = True)
+
calVideoFrameLength = 60
createCalibrationVideos(session,calVideoFrameLength)
@@ -81,7 +84,7 @@ def CalibrateCaptureVolume(session,board):
if not session.cameraCalFilePath.is_file():
error,merged = cgroup.calibrate_videos(vidnames, board)
cgroup.dump(session.cameraCalFilePath) #JSM NOTE - let's just use .yaml's unless there is some reason to use .toml
- mergename = session.sessionPath/'merged.npy'
+ mergename = session.dataArrayPath/'charuco_2d_points.npy'
np.save(mergename,merged)
else:
cgroup = CameraGroup.load(session.cameraCalFilePath) #load previous calibration config
@@ -96,7 +99,7 @@ def CalibrateCaptureVolume(session,board):
charucoarray = np.empty([session.numCams,n_frames,n_trackedPoints,1,2])
charucoarray[:] = np.nan
- data = np.load(session.sessionPath/'merged.npy',allow_pickle = True)
+ data = np.load(session.dataArrayPath/'charuco_2d_points.npy',allow_pickle = True)
for cam in range(session.numCams):
for count,frame in enumerate(framelist):
@@ -166,7 +169,7 @@ def CalibrateCaptureVolume(session,board):
# ax2.set_title('Charuco Point positions over time')
plt.show()
- path_to_charuco_array = session.dataArrayPath/'charuco_points.npy'
+ path_to_charuco_array = session.dataArrayPath/'charuco_3d_points.npy'
np.save(path_to_charuco_array, mean_charuco_fr_mar_dim)
return cgroup,mean_charuco_fr_mar_dim
diff --git a/freemocap/fmc_openpose.py b/freemocap/fmc_openpose.py
index 7294161d..a575015d 100644
--- a/freemocap/fmc_openpose.py
+++ b/freemocap/fmc_openpose.py
@@ -38,10 +38,10 @@ def runOpenPose(session, dummyRun=False):
session.openPose_imgPathList = openPose_imgPathList
yaml = YAML()
- data = yaml.load(session.yamlPath)
+ data = yaml.load(session.session_yaml_path)
data['openPose_imgPathList'] = openPose_imgPathList_yaml
data['openPose_jsonPathList'] = openPose_jsonPathList_yaml
- yaml.dump(data, session.yamlPath)
+ yaml.dump(data, session.session_yaml_path)
os.chdir(session.sessionPath)
diff --git a/freemocap/fmc_pyqtgraph.py b/freemocap/fmc_pyqtgraph.py
index 7bba8893..86182991 100644
--- a/freemocap/fmc_pyqtgraph.py
+++ b/freemocap/fmc_pyqtgraph.py
@@ -106,7 +106,7 @@ class PlaySkeletonWidget():
- self.charuco_mar_dim = np.load(session.dataArrayPath/'charuco_points.npy')
+ self.charuco_mar_dim = np.load(session.dataArrayPath/'charuco_3D_points.npy')
self.charucoScatterItem = gl.GLScatterPlotItem(pos=self.charuco_mar_dim, color=(1,1,1,.8), size=10, pxMode=False)
self.Skel3dViewWidget.addItem(self.charucoScatterItem)
diff --git a/freemocap/session.py b/freemocap/session.py
index 82c511e4..0a3c7b68 100644
--- a/freemocap/session.py
+++ b/freemocap/session.py
@@ -58,14 +58,14 @@ class Session: #self like "recording self"
self.syncedVidPath = self.sessionPath/'SyncedVideos'
pathList.append(self.syncedVidPath)
- self.calVideos = self.sessionPath/'CalVideos'
- pathList.append(self.calVideos)
+ self.calVidPath = self.sessionPath/'CalVideos'
+ pathList.append(self.calVidPath)
- self.dataArrays = self.sessionPath/'DataArrays'
- pathList.append(self.dataArrays)
+ self.dataArrayPath = self.sessionPath/'DataArrays'
+ pathList.append(self.dataArrayPath)
- self.DLCData = self.sessionPath/'DLCData'
- pathList.append(self.DLCData)
+ self.dlcDataPath = self.sessionPath/'DLCData'
+ pathList.append(self.dlcDataPath)
self.openPoseDataPath = self.sessionPath/'OpenPoseData'
pathList.append(self.openPoseDataPath)
@@ -115,10 +115,12 @@ class Session: #self like "recording self"
for key,value in session_dictionary_to_save['session_paths'].items():
session_dictionary_to_save['session_paths'][key] = str(value)
- session_yaml_path = self.sessionPath/'{}_config.yaml'.format(self.sessionID)
+ self.session_yaml_path = self.sessionPath/'{}_config.yaml'.format(self.sessionID)
+
session_yaml = YAML()
- with open(session_yaml_path,'w') as outfile:
+
+ with open(self.session_yaml_path,'w') as outfile:
session_yaml.dump(session_dictionary_to_save,outfile)
@@ -131,15 +133,26 @@ class Session: #self like "recording self"
self.sessionPath = recordPath/self.sessionID
self.sessionPath.mkdir(exist_ok=True)
- self.session_settings = self.load_session()
+ self.session_yaml_path = self.sessionPath/'{}_config.yaml'.format(self.sessionID)
+
+ if stage == 3:
+ #this is for the case of GoPro recordings/external recordings - if no config file exists, create one
+ if self.session_yaml_path.is_file():
+ self.session_settings = self.load_session()
+ else:
+ self.start_session({},{})
+ else:
+ self.session_settings = self.load_session()
+
+
def load_session(self):
- session_yaml_path = self.sessionPath/'{}_config.yaml'.format(self.sessionID)
+ #session_yaml_path = self.sessionPath/'{}_config.yaml'.format(self.sessionID)
session_yaml = YAML(typ='safe', pure=True)
- with open(session_yaml_path,'r') as fp:
+ with open(self.session_yaml_path,'r') as fp:
session_dictionary_to_load = session_yaml.load(fp)
session_settings_dictionary = session_dictionary_to_load #create a copy of the loaded dictionary
diff --git a/freemocap/initialization.py b/freemocap/webcamGUI.py
similarity index 94%
rename from freemocap/initialization.py
rename to freemocap/webcamGUI.py
index 812f2e34..8e22570f 100644
--- a/freemocap/initialization.py
+++ b/freemocap/webcamGUI.py
@@ -78,12 +78,13 @@ def initialize(session, stage, board):
sys.exit('Recording Cancelled')
# %% Stage Two Initalization
if stage == 2:
- session.sessionPath = filepath/'Data'/session.sessionID #create a session path based on the sessionID
+ # 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
+ # #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.config_settings['CamInputs']['ParameterDict']
diff --git a/parameters.yaml b/parameters.yaml
index 3b5b4f93..718b3f3c 100644
--- a/parameters.yaml
+++ b/parameters.yaml
@@ -20,11 +20,10 @@ default:
saved:
rotations:
- 0: 0
1: 0
2: 0
parameters:
- exposure: -5
+ exposure: -6
resWidth: 640
resHeight: 480
framerate: 30
diff --git a/runme_fmc_staged.py b/runme_fmc_staged.py
index 653611c1..98f0e433 100644
--- a/runme_fmc_staged.py
+++ b/runme_fmc_staged.py
@@ -1,4 +1,4 @@
-from freemocap import createvideo, initialization, recordingconfig, runcams, calibrate, fmc_mediapipe, fmc_openpose, fmc_deeplabcut, reconstruct3D, playskeleton, session
+from freemocap import createvideo, webcamGUI, runcams, calibrate, fmc_mediapipe, fmc_openpose, fmc_deeplabcut, reconstruct3D, playskeleton, session
from freemocap.fmc_pyqtgraph import PlayerDockedWindow
from pathlib import Path
@@ -25,15 +25,19 @@ if sesh.useDLC:
# %% Inputs to edit
-stage = 1 #set your starting stage here (stage = 1 will run the pipeline from webcams)
-sesh.debug = False
+stage = 3 #set your starting stage here (stage = 1 will run the pipeline from webcams)
+#6/30/21 log - AC
+ #running from State 1 works until Stage 4 openPose parsing - parseOpenPose needs to be updated, and the graphing stuff with file paths
+ #running from Stage 2 does not work right now
+ #running from Stage 3 for a webcam recording works until openPose parsing
+ #running from Stage 3 for an external recording works until openPose parsing (will break bc we need to set numCams/numFrames manually beforehand)
-sesh.sessionID = 'sesh_21-06-29_141040' #fill in if you are running from Stage 2 onwards
-#sesh.start_session()
+sesh.debug = False
+
+sesh.sessionID = 'sesh_21-06-30_153942' #fill in if you are running from Stage 2 onwards
-#sesh.initialize(stage)
if not sesh.sessionID:
@@ -60,7 +64,10 @@ board = CharucoBoard(7, 5,
# %% Initialization
#sesh.initialize(stage)
-initialization.initialize(sesh,stage,board)
+if stage ==2 or stage == 1:
+ webcamGUI.initialize(sesh,stage,board)
+else:
+ sesh.initialize(stage)
# %% Stage One
if stage <= 1:
@@ -141,7 +148,7 @@ else:
#reupdate the config_settings with mediapipe and openpose image paths
-sesh.config_settings = recordingconfig.load_config_yaml(sesh.yamlPath)
+#sesh.config_settings = recordingconfig.load_config_yaml(sesh.yamlPath)
# %% Stage Six