Skip to content

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

TypeScript

trying to resolve merge conflict

Aaron Cherian20d09f22a5d0
diff --cc .gitignore
index 76f61e96,9160080e..9cfc5988
--- a/.gitignore
+++ b/.gitignore
@@@ -5,8 -5,8 +5,13 @@@ Data
.vscode/
*.py[cod]
*$py.class
++<<<<<<< HEAD
+FreeMocap_Data/
+FreeMoCap_Data/
++=======
+ FreeMoCap_Data/
+
++>>>>>>> main
# C extensions
*.so
diff --cc freemocap/__init__.py
index fd82c6a1,11f5d922..0b858d0d
--- a/freemocap/__init__.py
+++ b/freemocap/__init__.py
@@@ -3,9 -3,12 +3,12 @@@ from ._version import get_version
__version__ = get_versions()["version"]
del get_versions
- from freemocap import fmc_runme
- from freemocap import play_skeleton_animation
+ from freemocap import fmc_runme, fmc_demo
- def RunMe(sessionID=None, stage=1, useOpenPose=True, openPoseDummyRun = False, useMediaPipe=False, useDLC=True, dlcConfigPath=None, recordVid=False, debug=False):
-def RunMe(sessionID=None,stage=1,useOpenPose=True,useMediaPipe=False,useDLC=True,dlcConfigPath=None,debug=False,setDataPath=False,userDataPath = None):
- fmc_runme.Run(sessionID,stage,useOpenPose,useMediaPipe,useDLC,dlcConfigPath,debug,setDataPath,userDataPath)
++def RunMe(sessionID=None,stage=1,useOpenPose=True, openPoseDummyRun = False, useMediaPipe=False,useDLC=True,dlcConfigPath=None,debug=False,setDataPath=False,userDataPath = None, recordVid=False):
++ fmc_runme.Run(sessionID,stage,useOpenPose,openPoseDummyRun, useMediaPipe,useDLC,dlcConfigPath,debug,setDataPath,userDataPath,recordVid)
+
+ def RunDemo():
+ sample_data_location = fmc_demo.DemoSetup() #run a bunch of GUIs, get the location of the directory where the data folder with the sample data is
+ fmc_runme.Run(sessionID = 'sesh_21-07-18_170130',stage = 6,useOpenPose = True,useDLC = True, userDataPath = sample_data_location)
- fmc_runme.Run(sessionID, stage, useOpenPose, openPoseDummyRun, useMediaPipe, useDLC, dlcConfigPath, recordVid, debug)
diff --cc freemocap/fmc_runme.py
index 3d03068b,b39bec31..e1f894d4
--- a/freemocap/fmc_runme.py
+++ b/freemocap/fmc_runme.py
@@@ -22,15 -21,11 +23,19 @@@ from aniposelib.boards import CharucoBo
import numpy as np
+ from ruamel.yaml import YAML
+
-
-def Run(sessionID=None,stage=1,useOpenPose=True,useMediaPipe=False,useDLC=True,dlcConfigPath=None,debug=False,setDataPath=False,userDataPath = None):
-
+def Run(sessionID=None,
+ stage=1,
+ useOpenPose=True,
+ openPoseDummyRun = False,
+ useMediaPipe=False,
+ useDLC=True,
+ dlcConfigPath=None,
+ recordVid = True,
- debug=False):
++ debug=False,
++ setDataPath = False,
++ userDataPath = None):
sesh = session.Session()
sesh.sessionID = sessionID
@@@ -38,23 -33,105 +43,121 @@@
sesh.useMediaPipe = useMediaPipe
sesh.useDLC= useDLC
sesh.debug = debug
-
+ sesh.setDataPath = setDataPath
+ sesh.userDataPath = userDataPath
+ sesh.dataFolderName = recordingconfig.dataFolder
+ if sesh.useDLC and stage < 5:
+ import deeplabcut as dlc
+ # sesh.dlcConfigPath = dlcConfigPath
++<<<<<<< HEAD
+ if sesh.useDLC and stage<=4:
+ 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
+
+
+ if sesh.useDLC and stage < 5:
+
+ 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)
+
++>>>>>>> main
# 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:
+ basePath = runmeGUI.RunChooseDataPathGUI(session)
+ #sesh.dataFolderPath = Path(basePath)/sesh.dataFolderName
+
+ elif sesh.userDataPath is not None:
+ basePath = sesh.userDataPath
+ else:
+ try:
+ current_path_to_data = preferences['saved']['path_to_save']
+ basePath = current_path_to_data
+ except KeyError('Saved Data path not found, please choose a new one'):
+ basePath = runmeGUI.RunChooseDataPathGUI(session)
+
+ dataFolder = Path(basePath)/sesh.dataFolderName
+ sesh.dataFolderPath = dataFolder
+
+ if not dataFolder.exists():
+ raise FileNotFoundError('No data folder located at: ' + str(dataFolder))
++<<<<<<< HEAD
+ dataFolder = Path.cwd()/'Data'
+ if dataFolder.exists():
+ if not sesh.sessionID: #if user has not provided a sessionID, use the most recent session
+ 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
+ else: #First time run! Make 'FreeMoCap_Data' Folder (and eventually, prompt to download sample data)
+ dataFolder.mkdir()
++=======
+ 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()
++>>>>>>> main
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`)
@@@ -115,23 -192,21 +218,31 @@@
np.save(sesh.dataArrayPath/'mediaPipeSkel_3d.npy', sesh.mediaPipeSkel_fr_mar_dim) #save data to npy
if sesh.useOpenPose:
- fmc_openpose.runOpenPose(sesh, dummyRun=False)
+ fmc_openpose.runOpenPose(sesh, dummyRun=openPoseDummyRun)
sesh.openPoseData_nCams_nFrames_nImgPts_XYC = fmc_openpose.parseOpenPose(sesh)
- sesh.openPoseSkel_fr_mar_dim = reconstruct3D.reconstruct3D(sesh,sesh.openPoseData_nCams_nFrames_nImgPts_XYC, confidenceThreshold=.1)
+ sesh.openPoseSkel_fr_mar_dim = reconstruct3D.reconstruct3D(sesh,sesh.openPoseData_nCams_nFrames_nImgPts_XYC, confidenceThreshold=.5)
np.save(sesh.dataArrayPath/'openPoseSkel_3d.npy', sesh.openPoseSkel_fr_mar_dim) #save data to npy
-
+ sesh.save_session()
sesh.syncedVidList = []
if sesh.useDLC:
for vid in sesh.syncedVidPath.glob('*.mp4'):
sesh.syncedVidList.append(str(vid))
++<<<<<<< HEAD
+ dlc.analyze_videos(str(sesh.dlcConfigPath),sesh.syncedVidList, destfolder= sesh.dlcDataPath, save_as_csv=True)
+
+ sesh.dlcData_nCams_nFrames_nImgPts_XYC = fmc_deeplabcut.parseDeepLabCut(sesh)
+ np.save(sesh.dataArrayPath / "deepLabCutData_2d.npy", sesh.dlcData_nCams_nFrames_nImgPts_XYC,)
+
+ sesh.dlc_fr_mar_dim = reconstruct3D.reconstruct3D(sesh,sesh.dlcData_nCams_nFrames_nImgPts_XYC, confidenceThreshold=.5)
+ np.save(sesh.dataArrayPath/'deepLabCut_3d.npy', sesh.dlc_fr_mar_dim) #save data to npy
++=======
+ for config_path in dlc_config_paths:
+ dlc.analyze_videos(config_path,sesh.syncedVidList, destfolder= sesh.dlcDataPath, save_as_csv=True)
+ sesh.dlcData_nCams_nFrames_nImgPts_XYC = fmc_deeplabcut.parseDeepLabCut(sesh, config_path)
+ sesh.dlc_fr_mar_dim = reconstruct3D.reconstruct3D(sesh,sesh.dlcData_nCams_nFrames_nImgPts_XYC, confidenceThreshold=.95)
+ np.save(sesh.dataArrayPath/'deepLabCut_3d.npy', sesh.dlc_fr_mar_dim) #save data to npy
++>>>>>>> main
sesh.save_session()
else:
print('Skipping Run MediaPipe')
@@@ -162,41 -237,28 +273,65 @@@
#sesh.config_settings = recordingconfig.load_config_yaml(sesh.yamlPath)
++<<<<<<< HEAD
+ # # %% Stage Six
+ # if stage <= 6:
+ # print ('Starting PyQT Animation')
+ # createvideo.createBodyTrackingVideos(sesh)
+ # displayVid = 1
+ # #if displayVid = 0, will show the synced videos
+ # #if displayVid = 1, will show the openPosed videos
+ # playWin = PlayerDockedWindow(sesh,displayVid)
+ # playWin.animate()
++=======
+ # %% Stage Six
+ if stage <= 6:
+ print ('Starting PyQT Animation')
+ #createvideo.createBodyTrackingVideos(sesh)
+ displayVid = 1
+ #if displayVid = 0, will show the synced videos
+ #if displayVid = 1, will show the openPosed videos
+ playWin = PlayerDockedWindow(sesh,displayVid)
+ playWin.animate()
++>>>>>>> main
# %% Stage Seven
if stage <= 7:
print('Starting Skeleton Plotting')
++<<<<<<< HEAD
+
+ play_skeleton_animation.PlaySkeletonAnimation(
+ sesh,
+ vidType=1,
+ startFrame=40,
+ azimuth=-90,
+ elevation=-80,
+ numCams = 4,
+ useOpenPose=sesh.useOpenPose,
+ useMediaPipe=sesh.useMediaPipe,
+ useDLC=sesh.useDLC,
+ recordVid = recordVid)
+
+ # playskeleton.ReplaySkeleton_matplotlib(
+ # sesh,
+ # vidType=1,
+ # startFrame=40,
+ # azimuth=-90,
+ # elevation=-80,
+ # useOpenPose=sesh.useOpenPose,
+ # useMediaPipe=sesh.useMediaPipe,
+ # useDLC=sesh.useDLC)
++=======
+ playskeleton.ReplaySkeleton_matplotlib(
+ sesh,
+ vidType=0,
+ startFrame=40,
+ azimuth=-90,
+ elevation=-80,
+ useOpenPose=sesh.useOpenPose,
+ useMediaPipe=sesh.useMediaPipe,
+ useDLC=sesh.useDLC)
++>>>>>>> main
# fmc_pyqtgraph.PlaySkeleton(
# sesh,
# vidType=1,