Skip to content

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

TypeScript

minor tweaks

jon matthisc616af2bb333
diff --git a/freemocap/fmc_runme.py b/freemocap/fmc_runme.py
index 68ae3655..23ece4fe 100644
--- a/freemocap/fmc_runme.py
+++ b/freemocap/fmc_runme.py
@@ -57,9 +57,8 @@ def RunMe(sessionID=None,
charucoSquareSize = 36,#mm - ~the size of the squares when printed on 8.5x11" paper based on parameters in ReadMe.md
calVideoFrameLength = .5,
startFrame = 0,
- useBlender = False,
+ useBlender = True,
resetBlenderExe = False,
- pauseBetweenStages =1
):
"""
Starts the freemocap pipeline based on either user-input values, or default values. Creates a new session class instance (called sesh)
@@ -145,7 +144,7 @@ def RunMe(sessionID=None,
console.rule(style="color({})".format(thisStage))
console.rule('Synchronizing Recorded Videos'.upper(),style="color({})".format(thisStage))
console.rule(style="color({})".format(thisStage))
- time.sleep(pauseBetweenStages)
+
runcams.SyncCams(sesh, sesh.timeStampData,sesh.numCamRange,sesh.vidNames,sesh.camIDs)
sesh.save_session()
else:
@@ -210,13 +209,13 @@ def RunMe(sessionID=None,
stage4_msg ='This step implements various computer vision that track the skeleton (and other objects) in the 2d videos, to produce the data that will be combined with the `camera projection matrices` from the calibration stage to produce the estimates of 3d movement. \n \n Each algorithm is different, but most involve using [bold magenta] convolutional neural networks [/bold magenta] trained from labeled videos to produce a 2d probability map of the likelihood that the tracked bodypart/object/feature (e.g. \'LeftElbow\') is in a given location. \n \n The peak of that distrubtion on each frame is recorded as the pixel-location of that item on that frame (e.g. \'LeftElbow(pixel-x, pixel-y, confidence\') where the a confidence value proportional to the underlying probability distribution (i.e. tall peaks in the probablitiy distribution -> high confidence that the LeftElbow actually is at this pixel-x, pixel-y location) \n \nThis part is crazy future tech sci fi stuff. Seriously unbelievable this kind of thing is possible ✨'
console.print(Padding(stage4_msg, (1,4)), overflow="fold", justify='center',style="color({})".format(thisStage))
console.rule(style="color({})".format(thisStage))
- time.sleep(pauseBetweenStages)
+
if sesh.useMediaPipe:
console.rule(style="color({})".format(thisStage))
console.rule('Running MediaPipe skeleton tracker - https://google.github.io/mediapipe', style="color({})".format(thisStage))
console.rule(style="color({})".format(thisStage))
- time.sleep(pauseBetweenStages)
+
if runMediaPipe:
fmc_mediapipe.runMediaPipe(sesh)
@@ -231,7 +230,7 @@ def RunMe(sessionID=None,
console.rule(style="color({})".format(thisStage))
console.rule('Running OpenPose skeleton tracker - https://github.com/CMU-Perceptual-Computing-Lab/openpose', style="color({})".format(thisStage))
console.rule(style="color({})".format(thisStage))
- time.sleep(pauseBetweenStages)
+
fmc_openpose.runOpenPose(sesh, runOpenPose=runOpenPose)
sesh.openPoseData_nCams_nFrames_nImgPts_XYC = fmc_openpose.parseOpenPose(sesh)
@@ -246,7 +245,7 @@ def RunMe(sessionID=None,
console.rule(style="color({})".format(thisStage))
console.rule('Running DeepLabCut :mouse: - https://deeplabcut.org', style="color({})".format(thisStage))
console.rule(style="color({})".format(thisStage))
- time.sleep(pauseBetweenStages)
+
for vid in sesh.syncedVidPath.glob('*.mp4'):
sesh.syncedVidList.append(str(vid))
@@ -263,29 +262,33 @@ def RunMe(sessionID=None,
print('Skipping 2d point tracking')
-
+ # %% Stage 5 - Use Blender to create output data files
if stage <=5:
- if useBlender == True:
- thisStage=5
- console.rule(style="color({})".format(thisStage))
- console.rule('Exporting Files...'.upper(), style="color({})".format(thisStage))
- console.rule('Hijacking Blender\'s file format converters to export FreeMoCap data as various file format (.blend, .usd, .gltf, .fbx)', style="color({})".format(thisStage))
- console.rule(style="color({})".format(thisStage))
- time.sleep(pauseBetweenStages)
+ try:
+ if useBlender == True:
+ thisStage=5
+ console.rule(style="color({})".format(thisStage))
+ console.rule('Exporting Files...'.upper(), style="color({})".format(thisStage))
+ console.rule('Hijacking Blender\'s file format converters to export FreeMoCap data as various file format (.blend, .usd, .gltf, .fbx)', style="color({})".format(thisStage))
+ console.rule(style="color({})".format(thisStage))
+
- #blenderPath = Path('C:\Program Files\Blender Foundation\Blender 2.93')
- #os.chdir(blenderExePath)
- output = subprocess.run([str(blenderPath), "--background", "--python", str(subprocessPath), "--", str(sesh.dataArrayPath/'mediaPipeSkel_3d.npy'), str(sesh.dataArrayPath)], capture_output=True, text=True, check=True)
- print(output)
+ #blenderPath = Path('C:\Program Files\Blender Foundation\Blender 2.93')
+ #os.chdir(blenderExePath)
+ output = subprocess.run([str(blenderPath), "--background", "--python", str(subprocessPath), "--", str(sesh.dataArrayPath/'mediaPipeSkel_3d.npy'), str(sesh.dataArrayPath)], capture_output=True, text=True, check=True)
+ print(output)
+ except:
+ console.print_exception()
+
- # %% Stage Five - Make Animation
+ # %% Stage 6 - Make Animation
if stage <= 6:
thisStage=6
console.rule(style="color({})".format(thisStage))
console.rule('Creating the Skreleton animation!'.upper(),style="color({})".format(thisStage))
console.print('The video creation is very slow. All of the animation making code is crazy slow, tbh. Sorry about that, future iterations will be better lol :sweat_smile:',overflow="fold", justify='center',style="color({})".format(thisStage))
console.rule(style="color({})".format(thisStage))
- time.sleep(pauseBetweenStages)
+
play_skeleton_animation.PlaySkeletonAnimation(