Skip to content

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

TypeScript

Added a whole, like, docked widget viewer thing!

jon matthis5b8f56821b36
diff --git a/freemocap/fmc_pyqtgraph.py b/freemocap/fmc_pyqtgraph.py
index af2639d3..65fb0328 100644
--- a/freemocap/fmc_pyqtgraph.py
+++ b/freemocap/fmc_pyqtgraph.py
@@ -1,293 +1,291 @@
from pyqtgraph.Qt import QtCore, QtGui
import pyqtgraph.opengl as gl
import pyqtgraph as pg
+import pyqtgraph.console
+from pyqtgraph.dockarea import Dock, DockArea
+import cv2
import numpy as np
from pathlib import Path
import sys
-class PlaySkeleton():
+class PlaySkeletonWidget():
def __init__(self, session):
#set up PyQT widget (the window that pops up and shows the plots, I think ? cribbed from - https://gist.github.com/markjay4k/da2f55e28514be7160a7c5fbf95bd243)
- self.app = QtGui.QApplication(sys.argv)
- self.QtWindow = gl.GLViewWidget()
- self.QtWindow.opts['distance'] = 2000
- self.QtWindow.setWindowTitle('SessionID: {}'.format(session.sessionID))
- self.QtWindow.setGeometry(0, 110, 1920, 1080)
- self.QtWindow.show()
-
- # create the background grids
- # gx = gl.GLGridItem()
- # gx.rotate(90, 0, 1, 0)
- # gx.translate(-2e3, 0, 0)
- # self.QtWindow.addItem(gx)
- # gy = gl.GLGridItem()
- # gy.rotate(90, 1, 0, 0)
- # gy.translate(0, -2e3, 0)
- # self.QtWindow.addItem(gy)
- # gz = gl.GLGridItem()
- # gz.translate(0, 0, -2e3)
- # self.QtWindow.addItem(gz)
-
- #load data to be plotted
- # if session.skel_fr_mar_dim:
- self.skel_fr_mar_dim = np.load(session.dataArrayPath/'openPoseSkel_3d.npy')
- self.skelScatterItem = gl.GLScatterPlotItem(pos=self.skel_fr_mar_dim, color=(1,0,1,.8), size=10, pxMode=False)
- self.QtWindow.addItem(self.skelScatterItem)
-
- # if session.dlc_fr_mar_dim:
- # self.dlc_fr_mar_dim = np.load(session.dataArrayPath/'mediaPipeSkel_3d.npy')
- # self.dlcScatterItem = gl.GLScatterPlotItem(pos=self.dlc_fr_mar_dim, color=(1,0,0,.8), size=40, pxMode=False)
- # QtWindow.addItem(self.dlcScatterItem)
-
-
- self.charuco_mar_dim = np.load(session.dataArrayPath/'charuco_points.npy')
- self.charucoScatterItem = gl.GLScatterPlotItem(pos=self.charuco_mar_dim, color=(1,1,1,.8), size=10, pxMode=False)
- self.QtWindow.addItem(self.charucoScatterItem)
-
- #set frame counter
- self.currentFrameNumber = 0
- self.framerate = 30 #frames per second
- self.frameDuration = 1000/self.framerate #milliseconds
-
- def start(self):
- if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
- QtGui.QApplication.instance().exec_()
-
- def update(self):
- self.skelScatterItem.setData(pos=self.skel_fr_mar_dim[self.currentFrameNumber,:,:])
- self.currentFrameNumber += 1
- if self.currentFrameNumber >= self.skel_fr_mar_dim.shape[0]:
- self.currentFrameNumber = 0
-
- def animate(self):
- timer = QtCore.QTimer()
- timer.timeout.connect(self.update)
- timer.start(self.frameDuration)
- self.start()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ # self.app = QtGui.QApplication(sys.argv)
+ self.Skel3dViewWidget = gl.GLViewWidget()
+ self.Skel3dViewWidget.opts['distance'] = 2000
+ self.Skel3dViewWidget.setWindowTitle('SessionID: {}'.format(session.sessionID))
+ self.Skel3dViewWidget.setGeometry(0, 110, 1920, 1080)
+ self.Skel3dViewWidget.show()
+ #load data to be plotted
+ self.useOpenPose = session.useOpenPose
+ if self.useOpenPose:
+ self.skel_fr_mar_dim = np.load(session.dataArrayPath/'openPoseSkel_3d.npy')
+ self.skelScatterItem = gl.GLScatterPlotItem(pos=self.skel_fr_mar_dim, color=(1,0,1,.8), size=10, pxMode=False)
+
+ self.Skel3dViewWidget.addItem(self.skelScatterItem)
+ #make skeleton line plots (numbers specify what order to connects the dots)
+ self.head = [17, 15, 0, 1, 0, 16, 18]
+ self.spine = [1,8]
+ self.rArm = [17, 15, 0, 16, 18]
+ self.rArm = [4 ,3 ,2 ,1]
+ self.lArm = [1, 5, 6, 7]
+ self.rLeg = [11 ,10, 9, 8]
+ self.lLeg = [14 ,13 ,12, 8]
+ self.rFoot = [11, 23,22, 11, 24]
+ self.lFoot = [14, 20, 19, 14, 21]
+ #Make some handy maps ;D
+ rHandIDstart = 25
+ lHandIDstart = rHandIDstart+21
+ self.rHand = np.array([0, 1, 2, 3, 4, False, 0, 5, 6, 7, 8, False, 0, 9, 10, 11, 12, False, 0, 13, 14, 15, 16, False, 0, 17, 18, 19, 20,]) + rHandIDstart
+ self.lHand = self.rHand + lHandIDstart
+ self.headLineItem = gl.GLLinePlotItem(pos=self.skel_fr_mar_dim[:,self.head,:], color=(1,1,1,.2), width=4., antialias=True)
+ self.Skel3dViewWidget.addItem(self.headLineItem)
+ self.spineLineItem = gl.GLLinePlotItem(pos=self.skel_fr_mar_dim[:,self.spine,:], color=(1,1,1,.9), width=4., antialias=True)
+ self.Skel3dViewWidget.addItem(self.spineLineItem)
+ self.rArmLineItem = gl.GLLinePlotItem(pos=self.skel_fr_mar_dim[:,self.rArm,:], color=(1,.2,.15,.9), width=4., antialias=True)
+ self.Skel3dViewWidget.addItem(self.rArmLineItem)
+ self.lArmLineItem = gl.GLLinePlotItem(pos=self.skel_fr_mar_dim[:,self.lArm,:], color=(.4,.6,1,.9), width=4., antialias=True)
+ self.Skel3dViewWidget.addItem(self.lArmLineItem)
+ self.rLegLineItem = gl.GLLinePlotItem(pos=self.skel_fr_mar_dim[:,self.rLeg,:], color=(1,.2,.15,.9), width=4., antialias=True)
+ self.Skel3dViewWidget.addItem(self.rLegLineItem)
+ self.lLegLineItem = gl.GLLinePlotItem(pos=self.skel_fr_mar_dim[:,self.lLeg,:], color=(.4,.6,1,.9), width=4., antialias=True)
+ self.Skel3dViewWidget.addItem(self.lLegLineItem)
+ self.rFootLineItem = gl.GLLinePlotItem(pos=self.skel_fr_mar_dim[:,self.rFoot,:], color=(1,.2,.15,.9), width=4., antialias=True)
+ self.Skel3dViewWidget.addItem(self.rFootLineItem)
+ self.lFootLineItem = gl.GLLinePlotItem(pos=self.skel_fr_mar_dim[:,self.lFoot,:], color=(.4,.6,1,.9), width=4., antialias=True)
+ self.Skel3dViewWidget.addItem(self.lFootLineItem)
+ # plot handybois
+ self.rHandLineItem = gl.GLLinePlotItem(pos=self.skel_fr_mar_dim[:,self.rHand,:], color=(.2,.4,1,.9), width=1., antialias=True)
+ # self.Skel3dViewWidget.addItem(self.rHandLineItem)
+
+ self.lHandLineItem = gl.GLLinePlotItem(pos=self.skel_fr_mar_dim[:,self.lHand,:], color=(1,.1,.05,.9), width=1., antialias=True)
+ # self.Skel3dViewWidget.addItem(self.lHandLineItem)
+
+ self.useDLC = session.useDLC
+ if self.useDLC:
+ # self.dlc_fr_mar_dim = np.load(session.dataArrayPath/'mediaPipeSkel_3d.npy')
+ self.dlc_fr_mar_dim = np.load(session.dataArrayPath/'deepLabCut_3d.npy')
+ self.dlcScatterItem = gl.GLScatterPlotItem(pos=self.dlc_fr_mar_dim, color=(1,0,0,.8), size=60, pxMode=False)
+ self.Skel3dViewWidget.addItem(self.dlcScatterItem)
+
+ self.dlc0LineItem = gl.GLLinePlotItem(pos=self.dlc_fr_mar_dim[:,0,:], color=(0,1,1,.5), width=4., antialias=True)
+ self.dlc1LineItem = gl.GLLinePlotItem(pos=self.dlc_fr_mar_dim[:,1,:], color=(1,0,1,.5), width=4., antialias=True)
+ self.dlc2LineItem = gl.GLLinePlotItem(pos=self.dlc_fr_mar_dim[:,2,:], color=(1,1,0,.5), width=4., antialias=True)
+
+ self.Skel3dViewWidget.addItem(self.dlc0LineItem)
+ self.Skel3dViewWidget.addItem(self.dlc1LineItem)
+ self.Skel3dViewWidget.addItem(self.dlc2LineItem)
+
+ self.tailLength = 10
+
+
+ self.charuco_mar_dim = np.load(session.dataArrayPath/'charuco_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)
+ #plot videos Frames!
+ #set frame counter
+ self.currentFrameNumber = 0
+ self.framerate = 50 #frames per second
+ self.frameDuration = 1000/self.framerate #milliseconds
+ # def start(self):
+ # if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
+ # QtGui.QApplication.instance().exec_()
+ def update(self):
+ #Plot Mr. Skreleton :D
+ #Plots the dots
+ self.skelScatterItem.setData(pos=self.skel_fr_mar_dim[self.currentFrameNumber,:,:])
+
+ #connect the dottos
+ self.headLineItem.setData(pos=self.skel_fr_mar_dim[self.currentFrameNumber, self.head,:])
+ self.spineLineItem.setData(pos=self.skel_fr_mar_dim[self.currentFrameNumber, self.spine,:])
+ self.rArmLineItem.setData(pos=self.skel_fr_mar_dim[self.currentFrameNumber, self.rArm,:])
+ self.lArmLineItem.setData(pos=self.skel_fr_mar_dim[self.currentFrameNumber, self.lArm,:])
+ self.rLegLineItem.setData(pos=self.skel_fr_mar_dim[self.currentFrameNumber, self.rLeg,:])
+ self.lLegLineItem.setData(pos=self.skel_fr_mar_dim[self.currentFrameNumber, self.lLeg,:])
+ self.rFootLineItem.setData(pos=self.skel_fr_mar_dim[self.currentFrameNumber, self.rFoot,:])
+ self.lFootLineItem.setData(pos=self.skel_fr_mar_dim[self.currentFrameNumber, self.lFoot,:])
+
+ self.rHandLineItem.setData(pos=self.skel_fr_mar_dim[self.currentFrameNumber, self.rHand,:])
+ self.lHandLineItem.setData(pos=self.skel_fr_mar_dim[self.currentFrameNumber, self.lHand,:])
+
+ if self.useDLC:
+ #Plot DeepLabCut data
+ self.dlcScatterItem.setData(pos=self.dlc_fr_mar_dim[self.currentFrameNumber,:,:])
+
+ if self.currentFrameNumber > self.tailLength:
+ self.tailIndexes = range(self.currentFrameNumber-self.tailLength , self.currentFrameNumber)
+ self.dlc0LineItem.setData(pos=self.dlc_fr_mar_dim[self.tailIndexes,0,:])
+ self.dlc1LineItem.setData(pos=self.dlc_fr_mar_dim[self.tailIndexes,1,:])
+ self.dlc2LineItem.setData(pos=self.dlc_fr_mar_dim[self.tailIndexes,2,:])
+ self.currentFrameNumber += 1
+ if self.currentFrameNumber >= self.skel_fr_mar_dim.shape[0]:
+ self.currentFrameNumber = 0
+ def animate(self):
+ timer = QtCore.QTimer()
+ timer.timeout.connect(self.update)
+ # timer.start(self.frameDuration)
+ timer.start(0)
+ # self.start()
+class VideoWindowWidget:
+ def __init__(self, vidNum, videoPath, session):
+ #set up video capture
+ self.vidCap = cv2.VideoCapture(str(videoPath))
+ success, image = self.vidCap.read()
+ self.vidCap.set(cv2.CAP_PROP_POS_FRAMES, 0) #reset video capture so things start on the first frame
+
+ self.videoWidget = pg.GraphicsLayoutWidget()
+ self.videoWidget.show() ## show widget alone in its own window
+ self.videoWidget.setWindowTitle('Video Name')
+ self.view = self.videoWidget.addViewBox()
+ ## lock the aspect ratio so pixels are always square
+ self.view.setAspectLocked(True)
+ ## Create image item
+ self.imgItem = pg.ImageItem(border='w')
+ self.view.addItem(self.imgItem)
+ ## Set initial view bounds
+ self.view.setRange(QtCore.QRectF(0, 0, image.shape[0], image.shape[1]))
+ #set image, I guess?
+ self.imgItem.setImage(image)
+ def update(self):
+ success, image = self.vidCap.read()
+ if success:
+ image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
+ image = cv2.rotate(image, cv2.ROTATE_90_CLOCKWISE)
+ self.imgItem.setImage(image)
+ else:
+ self.vidCap.set(cv2.CAP_PROP_POS_FRAMES, 0) #reset video capture so video will loop
+ success, image = self.vidCap.read()
+ self.imgItem.setImage(image)
-# def PlaySkeleton( session,
-# vidType=1,
-# startFrame=40,
-# azimuth=-90,
-# elevation=-80,
-# useOpenPose=True,
-# useMediaPipe=False,
-# useDLC=False):
-
-# mean_charuco_mar_dim = np.load(session.dataArrayPath/'charuco_points.npy')
-
-# # mean_charuco_mar_dim[:,0] -=mean_charuco_mar_dim[0,0]
-# # mean_charuco_mar_dim[:,1] -=mean_charuco_mar_dim[0,1]
-# # mean_charuco_mar_dim[:,2] -=mean_charuco_mar_dim[0,2]
-# global skel_fr_mar_dim, frameNum, dlc_fr_mar_dim, head, spine, rArm, lArm, rLeg, lLeg, rFoot, lFoot
+class PlayerDockedWindow:
+ def __init__(self, session):
-# for ii in range(20):
-# print('JON IS USING GLOBAL VARIABLES IN THE PYQTGRAPH PLOT FUNCTIONS IN A VERY IRRESPONSIBLE WAY. SHAME BE UPON HIM')
-
-# if useOpenPose:
-# skel_fr_mar_dim = np.load(session.dataArrayPath/'openPoseSkel_3d.npy')
-
-# if useMediaPipe:
-# mediaPipe_skel_fr_mar_dim = np.load(session.dataArrayPath/'mediaPipeSkel_3d.npy')
+ app = pg.mkQApp("DockArea Example")
+ self.win = QtGui.QMainWindow()
+ area = DockArea()
+ self.win.setCentralWidget(area)
+ winHeight = 1000
+ winWidth = 1900
+ self.win.resize(winHeight,winWidth)
+ self.win.setWindowTitle('FreeMoCap')
+
+ ## Create docks, place them into the window one at a time.
+ ## Note that size arguments are only a suggestion; docks will still have to
+ ## fill the entire dock area and obey the limits of their internal widgets.
+ dock_3dView = Dock('Session: {}'.format(session.sessionID), size=(1, 1), closable=True) ## give this dock the minimum possible size
+ dock_Console = Dock("Dock2 - Console", size=(winHeight,winWidth), closable=True)
+ dock_video0 = Dock("Video0", size=(1,1), closable=True)
+ dock_video1 = Dock("Video1", size=(1,1), closable=True)
+ dock_video2 = Dock("Video2", size=(1,1), closable=True)
+ dock_video3 = Dock("Video3", size=(1,1), closable=True)
+
+ area.addDock(dock_3dView, 'left') ## place d1 at left edge of dock area (it will fill the whole space since there are no other docks yet)
+ area.addDock(dock_video0, 'right') ## place d2 at right edge of dock area
+ area.addDock(dock_video1, 'right', dock_video0)## place d3 at bottom edge of d1
+ area.addDock(dock_video2, 'bottom',dock_video0) ## place d4 at right edge of dock area
+ area.addDock(dock_video3, 'left', dock_video2) ## place d5 at left edge of d1
-# if useDLC:
-# dlc_fr_mar_dim = np.load(session.dataArrayPath/'deepLabCut_3d.npy')
-# dlc0 = np.squeeze(dlc_fr_mar_dim[:,0,:])
-# dlc1 = np.squeeze(dlc_fr_mar_dim[:,1,:])
-# dlc2 = np.squeeze(dlc_fr_mar_dim[:,2,:])
-# ballTrailLen = 4
+ area.moveDock(dock_video1, 'right', dock_video0)
-
-# if useOpenPose:
-# imgPathList = session.config_settings['openPose_imgPathList']
-# session.numCams = len(session.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
-
+ ## Add widgets into each dock
-# # define Skeleton connections
-# head = [17, 15, 0, 16, 18]
-# # head = [ 15, 0, 16]
-# spine = [0,1,8]
-# rArm = [17, 15, 0, 16, 18]
-# rArm = [4 ,3 ,2 ,1]
-# lArm = [1, 5, 6, 7]
-# rLeg = [11 ,10, 9, 8]
-# lLeg = [14 ,13 ,12, 8]
-# rFoot = [11, 23,22, 11, 24]
-# lFoot = [14, 20, 19, 14, 21]
-
-# #Make some handy maps ;D
-# rHandIDstart = 25
-# lHandIDstart = rHandIDstart+21
-
-# thumb = np.array([0,1,2,3,4])
-# index = np.array([0, 5,6,7,8])
-# bird = np.array([0, 9,10,11,12])
-# ring = np.array([0, 13,14,15,16])
-# pinky = np.array([0, 17,18,19,20])
-
-# #This is mostly cribbed from the '3d Graphics:Scatter Plot' example from `python -m pyqtgraph.examples`
-# app = pg.mkQApp("GLScatterPlotItem Example")
-# QtWindow = gl.GLViewWidget()
-# QtWindow.opts['distance'] = 2000
-# QtWindow.show()
-# QtWindow.setWindowTitle('pyqtgraph example: GLScatterPlotItem')
-
-# # g = gl.GLGridItem()
-# # g.setSize(x=1e3, y=1e3, z=1)
-# # g.setSpacing(x=100, y=100)
-# # QtWindow.addItem(g)
-
-# charucoScatterItem = gl.GLScatterPlotItem(pos=mean_charuco_mar_dim, color=(1,1,1,.8), size=10, pxMode=False)
-# QtWindow.addItem(charucoScatterItem)
-
-# skelScatterItem = gl.GLScatterPlotItem(pos=skel_fr_mar_dim, color=(1,0,1,.8), size=10, pxMode=False)
-# QtWindow.addItem(skelScatterItem)
-
-# #make skeleton line plots
-# headLineItem = gl.GLLinePlotItem(pos=skel_fr_mar_dim[:,head,:], color=(1,1,1,.5), width=2., antialias=True)
-# QtWindow.addItem(headLineItem)
+ ## first dock gets save/restore buttons
+ w1 = pg.LayoutWidget()
+ label = QtGui.QLabel(""" -- DockArea Example --
+ This window has 6 Dock widgets in it. Each dock can be dragged
+ by its title bar to occupy a different space within the window
+ but note that one dock has its title bar hidden). Additionally,
+ the borders between docks may be dragged to resize. Docks that are dragged on top
+ of one another are stacked in a tabbed layout. Double-click a dock title
+ bar to place it in its own window.
+ """)
-# spineLineItem = gl.GLLinePlotItem(pos=skel_fr_mar_dim[:,spine,:], color=(1,1,1,.5), width=2., antialias=True)
-# QtWindow.addItem(spineLineItem)
+ w2 = pg.console.ConsoleWidget()
+ dock_Console.addWidget(w2)
-# rArmLineItem = gl.GLLinePlotItem(pos=skel_fr_mar_dim[:,rArm,:], color=(1,0,0,.5), width=2., antialias=True)
-# QtWindow.addItem(rArmLineItem)
-
-# lArmLineItem = gl.GLLinePlotItem(pos=skel_fr_mar_dim[:,lArm,:], color=(0,0,1,.5), width=2., antialias=True)
-# QtWindow.addItem(lArmLineItem)
-
-# rLegLineItem = gl.GLLinePlotItem(pos=skel_fr_mar_dim[:,rLeg,:], color=(1,0,0,.5), width=2., antialias=True)
-# QtWindow.addItem(rLegLineItem)
-
-# lLegLineItem = gl.GLLinePlotItem(pos=skel_fr_mar_dim[:,lLeg,:], color=(0,0,1,.5), width=2., antialias=True)
-# QtWindow.addItem(lLegLineItem)
-
-# rFootLineItem = gl.GLLinePlotItem(pos=skel_fr_mar_dim[:,rFoot,:], color=(1,0,0,.5), width=2., antialias=True)
-# QtWindow.addItem(rFootLineItem)
+ self.playSkel = PlaySkeletonWidget(session)
+
+ dock_3dView.addWidget(self.playSkel.Skel3dViewWidget)
-# lFootLineItem = gl.GLLinePlotItem(pos=skel_fr_mar_dim[:,lFoot,:], color=(0,0,1,.5), width=2., antialias=True)
-# QtWindow.addItem(lFootLineItem)
+ self.syncedVidPathList = []
+ for vidPath in session.syncedVidPath.glob('*.mp4'):
+ self.syncedVidPathList.append(vidPath)
+ self.video0Widget = VideoWindowWidget(0,str(self.syncedVidPathList[0]), session)
+ dock_video0.addWidget(self.video0Widget.videoWidget )
+ self.video1Widget = VideoWindowWidget(1,str(self.syncedVidPathList[1]),session)
+ dock_video1.addWidget(self.video1Widget.videoWidget )
+ self.video2Widget = VideoWindowWidget(2,str(self.syncedVidPathList[2]), session)
+ dock_video2.addWidget(self.video2Widget.videoWidget )
-# dlcScatterItem = gl.GLScatterPlotItem(pos=dlc_fr_mar_dim, color=(1,0,0,.8), size=40, pxMode=False)
-# QtWindow.addItem(dlcScatterItem)
+ self.video3Widget = VideoWindowWidget(3,str(self.syncedVidPathList[3]),session)
+ dock_video3.addWidget(self.video3Widget.videoWidget )
-# dlc0LineItem = gl.GLLinePlotItem(pos=dlc_fr_mar_dim[:,0,:], color=(0,1,1,.5), width=4., antialias=True)
-# dlc1LineItem = gl.GLLinePlotItem(pos=dlc_fr_mar_dim[:,1,:], color=(1,0,1,.5), width=4., antialias=True)
-# dlc2LineItem = gl.GLLinePlotItem(pos=dlc_fr_mar_dim[:,2,:], color=(1,1,0,.5), width=4., antialias=True)
+ self.win.show()
-# QtWindow.addItem(dlc0LineItem)
-# QtWindow.addItem(dlc1LineItem)
-# QtWindow.addItem(dlc2LineItem)
-
-
-# frameNum = 0
-# numFrames = skel_fr_mar_dim.shape[0]
-# def update():
-# #iterate through frames
-# global frameNum, skel_fr_mar_dim, head, spine, rArm, lArm, rLeg, lLeg, rFoot, lFoot
-# skelScatterItem.setData(pos=skel_fr_mar_dim[frameNum,:,:])
+ def update(self):
+ self.playSkel.update()
+ self.video0Widget.update()
+ self.video1Widget.update()
+ self.video2Widget.update()
+ self.video3Widget.update()
-# headLineItem.setData(pos=skel_fr_mar_dim[frameNum,head,:])
-# spineLineItem.setData(pos=skel_fr_mar_dim[frameNum,spine,:])
-# rArmLineItem.setData(pos=skel_fr_mar_dim[frameNum,rArm,:])
-# lArmLineItem.setData(pos=skel_fr_mar_dim[frameNum,lArm,:])
-# rLegLineItem.setData(pos=skel_fr_mar_dim[frameNum,rLeg,:])
-# lLegLineItem.setData(pos=skel_fr_mar_dim[frameNum,lLeg,:])
-# rFootLineItem.setData(pos=skel_fr_mar_dim[frameNum,rFoot,:])
-# lFootLineItem.setData(pos=skel_fr_mar_dim[frameNum,lFoot,:])
-
-# dlcScatterItem.setData(pos=dlc_fr_mar_dim[frameNum,:,:])
-
-# tailLength = 10
-# if frameNum > tailLength:
-# tailIndexes = range(frameNum-tailLength, frameNum)
-# else:
-# tailIndexes = range(frameNum)
-# dlc0LineItem.setData(pos=dlc_fr_mar_dim[tailIndexes,0,:])
-# dlc1LineItem.setData(pos=dlc_fr_mar_dim[tailIndexes,1,:])
-# dlc2LineItem.setData(pos=dlc_fr_mar_dim[tailIndexes,2,:])
-
-# frameNum+=1
-# if frameNum >= numFrames:
-# frameNum = 0
-
-# t = QtCore.QTimer()
-# t.timeout.connect(update)
-# t.start(25)
-# pg.mkQApp().exec_()
-# f=9
+ def animate(self):
+ timer = QtCore.QTimer()
+ timer.timeout.connect(self.update)
+ timer.start(self.playSkel.frameDuration)
+ self.start()
+
+ def start(self):
+ if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
+ QtGui.QApplication.instance().exec_()
\ No newline at end of file
diff --git a/runme_fmc_staged.py b/runme_fmc_staged.py
index 3539b1da..ff115ee8 100644
--- a/runme_fmc_staged.py
+++ b/runme_fmc_staged.py
@@ -1,5 +1,5 @@
from freemocap import createvideo, initialization, runcams, calibrate, fmc_mediapipe, fmc_openpose, fmc_deeplabcut, reconstruct3D, playskeleton, session
-from freemocap.fmc_pyqtgraph import PlaySkeleton
+from freemocap.fmc_pyqtgraph import PlayerDockedWindow
from pathlib import Path
import os
@@ -11,12 +11,12 @@ import numpy as np
sesh = session.Session()
-useOpenPose= True
-useMediaPipe = True
-useDLC=True
+sesh.useOpenPose= True
+sesh.useMediaPipe = True
+sesh.useDLC=True
-if useDLC:
- import deeplabcut as dlc
+if sesh.useDLC:
+ # import deeplabcut as dlc
sesh.dlcConfigPath = Path("C:\\Users\\jonma\\Dropbox\\GitKrakenRepos\\freemocap\\DLC_Models\\PinkGreenRedJugglingBalls-JSM-2021-05-31\\config.yaml")
@@ -76,19 +76,19 @@ else:
# %% Stage Four
if stage <= 4:
print('Starting Track Image Points')
- if useMediaPipe:
+ if sesh.useMediaPipe:
fmc_mediapipe.runMediaPipe(sesh)
sesh.mediaPipeData_nCams_nFrames_nImgPts_XYC = fmc_mediapipe.parseMediaPipe(sesh)
sesh.mediaPipeSkel_fr_mar_dim = reconstruct3D.reconstruct3D(sesh,sesh.mediaPipeData_nCams_nFrames_nImgPts_XYC, confidenceThreshold=.1)
np.save(sesh.dataArrayPath/'mediaPipeSkel_3d.npy', sesh.mediaPipeSkel_fr_mar_dim) #save data to npy
- if useOpenPose:
+ if sesh.useOpenPose:
fmc_openpose.runOpenPose(sesh, dummyRun=True)
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)
np.save(sesh.dataArrayPath/'openPoseSkel_3d.npy', sesh.openPoseskel_fr_mar_dim) #save data to npy
- if useDLC:
+ if sesh.useDLC:
sesh.syncedVidList = []
for vid in sesh.syncedVidPath.glob('*.mp4'):
sesh.syncedVidList.append(str(vid))
@@ -146,8 +146,10 @@ if stage <= 7:
# useMediaPipe=useMediaPipe,
# useDLC=useDLC)
- playSkel = PlaySkeleton(sesh)
- playSkel.animate()
+ # playSkel = PlaySkeleton(sesh)
+ # playSkel.animate()
+ playWin =PlayerDockedWindow(sesh)
+ playWin.animate()
else:
print('Skipping Skeleton Plotting')