Skip to content

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

TypeScript

Getting openpose working

Aaron Cheriana9b8e3391f2c
diff --git a/freemocap/createvideo.py b/freemocap/createvideo.py
index 165bc5eb..7462a8b2 100644
--- a/freemocap/createvideo.py
+++ b/freemocap/createvideo.py
@@ -37,7 +37,7 @@ def createBodyTrackingVideos(session):
if session.useOpenPose:
- for count,videoPath in enumerate(session.config_settings['openPose_imgPathList']):
+ for count,videoPath in enumerate(session.session_settings['openPose_imgPathList']):
frame_array = []
vidSavePath = str(session.openPoseDataPath/'openPoseVideo_cam{}.mp4'.format(count))
videoPath = Path(videoPath)
diff --git a/freemocap/fmc_openpose.py b/freemocap/fmc_openpose.py
index a575015d..0c04d8b4 100644
--- a/freemocap/fmc_openpose.py
+++ b/freemocap/fmc_openpose.py
@@ -83,7 +83,8 @@ def parseOpenPose(session):
## %%
## load in data from json files
- numFrames = int(len(list(Path(session.openPose_jsonPathList[0]).glob('*')))) #lol
+ #numFrames = int(len(list(Path(session.openPose_jsonPathList[0]).glob('*')))) #lol
+ numFrames = session.numFrames
numMarkers= int(int(len(dataFrameHeader)/3))
numCams = int(session.numCams)
@@ -121,7 +122,7 @@ def parseOpenPose(session):
# session.dataFrameHeader = dataFrameHeader
# session.numImgPoints = numImgPoints
- session.numFrames = frameNum #NOTE - Need to find a safer way to get this number
+ #session.numFrames = frameNum #NOTE - Need to find a safer way to get this number
path_to_openpose_2d = session.dataArrayPath/'openPoseData_2d.npy'
np.save(path_to_openpose_2d, openPoseData_nCams_nFrames_nImgPts_XYC)
diff --git a/freemocap/fmc_pyqtgraph.py b/freemocap/fmc_pyqtgraph.py
index 86182991..ccc6272e 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_3D_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/parameters.yaml b/freemocap/parameters.yaml
index ff03bdc4..6d326a0d 100644
--- a/freemocap/parameters.yaml
+++ b/freemocap/parameters.yaml
@@ -1,27 +1,28 @@
-#default parameters
-
-
-
-default:
- rotations: {}
- parameters:
- exposure: -5
- resWidth: 640
- resHeight: 480
- framerate: 25
- codec: DIVX
-
-#saved parameters
-
-
-
-
-saved:
- rotations:
- 0: 0
- parameters:
- exposure: -6
- resWidth: 640
- resHeight: 480
- framerate: 30
- codec: H264
+#default parameters
+
+
+
+default:
+ rotations: {}
+ parameters:
+ exposure: -5
+ resWidth: 640
+ resHeight: 480
+ framerate: 25
+ codec: DIVX
+
+#saved parameters
+
+
+
+
+saved:
+ rotations:
+ 1: 0
+ 2: 0
+ parameters:
+ exposure: -6
+ resWidth: 640
+ resHeight: 480
+ framerate: 30
+ codec: H264
diff --git a/freemocap/playskeleton.py b/freemocap/playskeleton.py
index 32d4d05e..56f0b57a 100644
--- a/freemocap/playskeleton.py
+++ b/freemocap/playskeleton.py
@@ -34,7 +34,7 @@ def ReplaySkeleton_matplotlib( session,
useDLC=False):
- mean_charuco_fr_mar_dim = np.load(session.dataArrayPath/'charuco_points.npy')
+ mean_charuco_fr_mar_dim = np.load(session.dataArrayPath/'charuco_3d_points.npy')
if useOpenPose:
skel_fr_mar_dim = np.load(session.dataArrayPath/'openPoseSkel_3d.npy')
@@ -51,13 +51,13 @@ def ReplaySkeleton_matplotlib( session,
if useOpenPose:
- imgPathList = session.config_settings['openPose_imgPathList']
- session.numCams = len(session.openPose_imgPathList)
+ imgPathList = session.session_settings['openPose_imgPathList']
+
camImgPathList = {}
for cam in range(session.numCams):
camImgPathList[cam] = list(sorted(Path(imgPathList[cam]).glob('*.png')))
- session.numFrames = len(camImgPathList[cam]) #will need to perhaps put a check in on whether numFrames between cameras are the same
+ #session.numFrames = len(camImgPathList[cam]) #will need to perhaps put a check in on whether numFrames between cameras are the same
# define Skeleton connections
@@ -215,20 +215,20 @@ def ReplaySkeleton_matplotlib( session,
useMediaPipe=False,
useDLC=False):
-
- mean_charuco_fr_mar_dim = np.load(session.dataArrayPath/'charuco_points.npy')
+ session.imOutPath.mkdir(exist_ok = True)
+ mean_charuco_fr_mar_dim = np.load(session.dataArrayPath/'charuco_3d_points.npy')
if session.useMediaPipe:
mediaPipe_skel_fr_mar_dim = np.load(session.dataArrayPath/'mediaPipeSkel_3d.npy')
- imgPathList = session.config_settings['mediaPipe_imgPathList']
+ imgPathList = session.session_settings['mediaPipe_imgPathList']
session.numCams = len(session.mediaPipe_imgPathList)
if session.useOpenPose:
skel_fr_mar_dim = np.load(session.dataArrayPath/'openPoseSkel_3d.npy')
- imgPathList = session.config_settings['openPose_imgPathList']
- session.numCams = len(session.openPose_imgPathList)
+ imgPathList = session.session_settings['openPose_imgPathList']
+ #session.numCams = len(session.openPose_imgPathList)
if session.useDLC:
dlc_fr_mar_dim = np.load(session.dataArrayPath/'deepLabCut_3d.npy')
@@ -243,7 +243,7 @@ def ReplaySkeleton_matplotlib( session,
camImgPathList = {}
for cam in range(session.numCams):
camImgPathList[cam] = list(sorted(Path(imgPathList[cam]).glob('*.png')))
- session.numFrames = len(camImgPathList[cam]) #will need to perhaps put a check in on whether numFrames between cameras are the same
+ #session.numFrames = len(camImgPathList[cam]) #will need to perhaps put a check in on whether numFrames between cameras are the same
# define Skeleton connections
diff --git a/runme_fmc_staged.py b/runme_fmc_staged.py
index 98f0e433..adb895e7 100644
--- a/runme_fmc_staged.py
+++ b/runme_fmc_staged.py
@@ -25,18 +25,23 @@ if sesh.useDLC:
# %% Inputs to edit
-stage = 3 #set your starting stage here (stage = 1 will run the pipeline from webcams)
+stage = 1 #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)
+#6/31/21 log -AC
+#running from Stages 3,4,6,7 and 8 work until the end now
+#stage 1 till the end presumably works - still need to do a full run thruogh
+#stage 2 still out of order
+#**only tested with openPose - mediaPipe probably wont work
sesh.debug = False
-sesh.sessionID = 'sesh_21-06-30_153942' #fill in if you are running from Stage 2 onwards
+sesh.sessionID = 'sesh_21-07-01_142123' #fill in if you are running from Stage 2 onwards
@@ -57,7 +62,7 @@ board = CharucoBoard(7, 5,
marker_bits=4, dict_size=250)
-
+sesh.board = board
#sesh.input_stage = stage
@@ -154,7 +159,7 @@ else:
# %% Stage Six
if stage <= 6:
print ('Starting PyQT Animation')
- #createvideo.createBodyTrackingVideos(sesh)
+ createvideo.createBodyTrackingVideos(sesh)
displayVid = 1
#if displayVid = 0, will show the synced videos
#if displayVid = 1, will show the openPosed videos