Free Motion Capture for Everyone πβ¨
TypeScript
changing submodule names and adding DLC support
jon matthis2bf2b155dcc0
diff --git a/freemocap/calibrate.py b/freemocap/calibrate.pyindex eae7dfc2..279cb514 100644--- a/freemocap/calibrate.py+++ b/freemocap/calibrate.py@@ -1,13 +1,11 @@from aniposelib.cameras import CameraGroup-from freemocap import stolenfromanipose-from aniposelib.utils import load_pose2d_fnamesimport numpy as npimport cv2import matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3D-from freemocap import reconstruct3D, stolenfromanipose+from freemocap import reconstruct3D, fmc_aniposeimport osfrom rich.progress import track@@ -25,7 +23,7 @@ def CalibrateCaptureVolume(session,board):cam_names.append(str(count))session.numCams = count- cgroup = stolenfromanipose.CameraGroup.from_names(cam_names, fisheye=True) #Looking through their code... it looks lke the 'fisheye=True' doesn't do much (see 2020-03-29 obsidian note)+ cgroup = fmc_anipose.CameraGroup.from_names(cam_names, fisheye=True) #Looking through their code... it looks lke the 'fisheye=True' doesn't do much (see 2020-03-29 obsidian note)@@ -76,16 +74,16 @@ def CalibrateCaptureVolume(session,board):# init_extrinsics=True)#%% End of the copy-paste of the inner bits of `cgroup.calibrate_videos` - END- #JSM NOTE - need add method to extract Charuco board points from the calibrate_videos pipeline+ #JSM NOTE - need add method to extract Charuco board points from the calibrate_videos pipeline- ## if you need to save and load- ## example saving and loading for later- 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'- np.save(mergename,merged)- else:- cgroup = CameraGroup.load(session.cameraCalFilePath) #load previous calibration config+ ## if you need to save and load+ ## example saving and loading for later+ 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'+ np.save(mergename,merged)+ # else:+ # cgroup = CameraGroup.load(session.cameraCalFilePath) #load previous calibration configsession.cgroup = cgroupn_frames= 40@@ -154,9 +152,9 @@ def CalibrateCaptureVolume(session,board):my = np.nanmean(my)mz = np.nanmean(mz)- ax1.set_xlim(mx-100,mx+100)- ax1.set_ylim(my-100,my+100)- ax1.set_zlim(mz-100,mz+100)+ ax1.set_xlim(mx-1000,mx+1000)+ ax1.set_ylim(my-1000,my+1000)+ ax1.set_zlim(mz-1000,mz+1000)# #charuco points over time# ax2 = fig.add_subplot(122)diff --git a/freemocap/stolenfromanipose.py b/freemocap/fmc_anipose.pysimilarity index 100%rename from freemocap/stolenfromanipose.pyrename to freemocap/fmc_anipose.pydiff --git a/freemocap/dlc.py b/freemocap/fmc_deeplabcut.pysimilarity index 100%rename from freemocap/dlc.pyrename to freemocap/fmc_deeplabcut.pydiff --git a/freemocap/runopenpose.py b/freemocap/fmc_openpose.pysimilarity index 100%rename from freemocap/runopenpose.pyrename to freemocap/fmc_openpose.pydiff --git a/freemocap/initialization.py b/freemocap/initialization.pyindex b787b427..a076dfe5 100644--- a/freemocap/initialization.py+++ b/freemocap/initialization.py@@ -7,7 +7,7 @@ import pandas as pdimport numpy as npfrom freemocap.webcam import recordGUI,camsetup-from freemocap import recordingconfig, stolenfromanipose+from freemocap import recordingconfig, fmc_aniposedef initialize(session, stage, board):@@ -153,7 +153,7 @@ def initialize(session, stage, board):session.openPoseData_nCams_nFrames_nImgPts_XY = np.load(session.dataArrayPath/'openPoseData_nCams_nFrames_nImgPts_XY.npy')calibrationFile = '{}_calibration.yaml'.format(session.sessionID)session.cameraConfigFilePath = session.sessionPath/calibrationFile- session.cgroup = stolenfromanipose.CameraGroup.load(session.cameraConfigFilePath)+ session.cgroup = fmc_anipose.CameraGroup.load(session.cameraConfigFilePath)if stage == 7:diff --git a/freemocap/playskeleton.py b/freemocap/playskeleton.pyindex 757aef3b..b0edabb2 100644--- a/freemocap/playskeleton.py+++ b/freemocap/playskeleton.py@@ -237,9 +237,9 @@ def ReplaySkeleton(session, vidType, startframe,azimuth,elevation):axMain.set_ylabel('y')axMain.set_zlabel('z')- axMain.set_xlim(-100,100)- axMain.set_ylim(-100,100)- axMain.set_zlim(100,300)+ axMain.set_xlim(-1000,1000)+ axMain.set_ylim(-1000,1000)+ axMain.set_zlim(1000,3000)if vidType ==0:passdiff --git a/parameters.yaml b/parameters.yamlindex e997605e..fc70851d 100644--- a/parameters.yaml+++ b/parameters.yaml@@ -18,10 +18,10 @@ default:saved:rotations:- 0: 0- 1: 0- 2: 0- 4: 0+ 0: 90+ 1: 270+ 2: 90+ 4: 90parameters:exposure: -7resWidth: 640diff --git a/runme_fmc_staged.py b/runme_fmc_staged.pyindex 0c808575..bfd64dae 100644--- a/runme_fmc_staged.py+++ b/runme_fmc_staged.py@@ -1,4 +1,4 @@-from freemocap import createvideo, initialization, runcams, calibrate, runopenpose, reconstruct3D, playskeleton, session+from freemocap import createvideo, initialization, runcams, calibrate, fmc_openpose, reconstruct3D, playskeleton, sessionfrom aniposelib.boards import CharucoBoard, Checkerboard@@ -11,14 +11,16 @@ sesh = session.Session(useOpenPose=True,useDLC=False)# %% Inputs to editstage = 1 #set your starting stage here (stage = 1 will run the pipeline from webcams)-sesh.debug = True+sesh.debug = Falsesesh.sessionID = '' #fill in if you are running from Stage 2 onwardsboard = 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`)#marker_length=.8,- square_length = 7,- marker_length = 6.8,+ # square_length = 121, #big boi charuco+ # marker_length = 98,+ square_length = 82,#regular boi charuco+ marker_length = 65,marker_bits=4, dict_size=250)@@ -32,38 +34,43 @@ board = CharucoBoard(7, 5,initialization.initialize(sesh,stage,board)# %% Stage One-if not stage > 1:+if stage <= 1:runcams.RecordCams(sesh, sesh.cam_inputs, sesh.parameterDictionary, sesh.rotationInputs)else:print('Skipping Video Recording')# %% Stage Two-if not stage > 2:+if stage <= 2:runcams.SyncCams(sesh, sesh.timeStampData,sesh.numCamRange,sesh.vidNames,sesh.camIDs)else:print('Skipping Video Syncing')# %% Stage Three-if not stage > 3:+if stage <= 3:sesh.cgroup, sesh.mean_charuco_fr_mar_dim = calibrate.CalibrateCaptureVolume(sesh,board)else:print('Skipping Calibration')# %% Stage Four-if not stage > 4:- runopenpose.runOpenPose(sesh)+if stage <= 4:+ fmc_openpose.runOpenPose(sesh)else:print('Skipping Running OpenPose')# %% Stage Five-if not stage > 5:- sesh.openPoseData_nCams_nFrames_nImgPts_XY = runopenpose.parseOpenPose(sesh)+if stage <= 5:+ sesh.openPoseData_nCams_nFrames_nImgPts_XY = fmc_openpose.parseOpenPose(sesh)else:print('Skipping Parse OpenPose')+++# #%% process DLC++# deeplabcut.analyze_videos(sesh.dlcConfigPath,sesh.sessionPath/'SyncedVideos', destfolder= sesh.dlcDataPath)# %% Stage Six-if not stage > 6:+if stage <= 6:openPose_params = sesh.openPoseData_nCams_nFrames_nImgPts_XY.shape[0:3]sesh.skel_fr_mar_dim = reconstruct3D.reconstruct3D(sesh,sesh.openPoseData_nCams_nFrames_nImgPts_XY, openPose_params)@@ -71,19 +78,19 @@ if not stage > 6:np.save(path_to_skel_points, sesh.skel_fr_mar_dim)else:print('Skipping Skeleton Reconstruction')-+# %% Stage Seven-if not stage > 7:+if stage <= 7:playskeleton.ReplaySkeleton(sesh,1,40,-90,-75)else:print('Skipping Skeleton Plotting')# %% Stage Eight-if not stage > 8:+if stage <= 8:createvideo.createVideo(sesh)else:print('Skipping Video Creation')-f = 2\ No newline at end of file+f = 9\ No newline at end of file