Example #1
0
    def LoadMotion(self, filename='07_01.c3d'):

        s,p,f = c3d.read_c3d(filename)

        # self.d 3 x np x nf
        self.d = np.ndarray(shape=(3, 15, np.shape(f)[0]))
        ind = []
        for i in range(len(self.marker_set)):
            ind.append(p.index(s[0] + self.marker_set[i]))

        # f.T : 3 x np x nf 
        self.d = f[0:nframes, ind, :].T
        self.g.pos={}
        for i in range(15):
            self.g.pos[i]=(self.d[1,i,0],self.d[2,i,0])
Example #2
0
    def LoadMotion(self, filename='07_01.c3d', nframes=126):

        s, p, f = c3d.read_c3d(filename)

        # self.d 3 x np x nf
        self.d = np.ndarray(shape=(3, 15, np.shape(f)[0]))
        ind = []
        for i in range(len(self.marker_set)):
            ind.append(p.index(s[0] + self.marker_set[i]))

        # f.T : 3 x np x nf
        self.d = f[0:nframes, ind, :].T
        self.g.pos = {}
        for i in range(15):
            self.g.pos[i] = (self.d[1, i, 0], self.d[2, i, 0])
Example #3
0
    def loadC3D(self, filename='07_01.c3d', nframes=126):
        """ load nframes of motion capture C3D file 

        Parameters
        ----------

        filename : string
            file name 
        nframes  : int 
            number of frames 

        """

        self.nframes = nframes
        self.filename = filename

        s, p, f = c3d.read_c3d(filename)

        #pdb.set_trace()
        CM_TO_M = 0.01
        # self.d 3 x np x nf
        # 
        self.d = np.ndarray(shape=(3, self.npoints, np.shape(f)[0]))
        #if self.d[2,:,:].max()>50:
        ind = []
        for i in self.nodes_Id:
            ind.append(p.index(s[0] + self.nodes_Id[i]))

        # f.T : 3 x np x nf
        self.d = f[0:nframes, ind, :].T
        self.d = self.d*CM_TO_M
        self.g.pos = {}
        for i in range(self.npoints):
            self.g.pos[i] = (self.d[1, i, 0], self.d[2, i, 0])
        #
        # Extension of cylinder
        #
        self.g.add_node(15)
        pm  = (self.d[:, 9, 0] + self.d[:, 10, 0])/2.
        pmf = (self.d[:, 9, :] + self.d[:, 10, :])/2.
        pmf = pmf[:,np.newaxis,:]
        self.d = np.concatenate((self.d,pmf),axis=1)
        self.g.add_edge(0, 15)
        self.g.pos[15] = (pm[1],pm[2])
        self.g[0][15]['radius']=0.1
Example #4
0
    def loadC3D(self, filename='07_01.c3d', nframes=126 ,unit='cm'):
        """ load nframes of motion capture C3D file 

        Parameters
        ----------

        filename : string
            file name 
        nframes  : int 
            number of frames 

        """

        if 'pg' in dir(self):
            del self.pg


        s, p, f, info = c3d.read_c3d(filename)

        self.mocapinfo = info
        
        self.filename = filename
        if nframes<>-1:
            self.nframes  = nframes
        else:
            self.nframes = np.shape(f)[0] 
        #
        # s : prefix 
        # p : list of points name 
        # f : nframe x npoints x 3 
        #

        CM_TO_M = 0.01
        
        # duration of the motion capture snapshot

        self.Tmocap = self.nframes / info['VideoFrameRate']

        #
        # motion capture data 
        #
        # self.d   :   3 x npoints x nframes
        # 

        self.npoints = 15

        self.d = np.ndarray(shape=(3, self.npoints, self.nframes))

        #if self.d[2,:,:].max()>50:
        # extract only known nodes in nodes_Id     
        ind = []
        for i in self.nodes_Id:
            if self.nodes_Id[i]<>'BOTT':
                ind.append(p.index(s[0] + self.nodes_Id[i]))

        # f.T : 3 x npoints x nframe 
        #
        # cm to meter conversion if required 
        #
        self.d = f[0:nframes, ind, :].T
        if unit=='cm':
            self.d = self.d*CM_TO_M
        
        #
        # Creating the body graph structure 
        #
        self.g.pos = {}
        for i in range(self.npoints):
            self.g.pos[i] = (self.d[1, i, 0], self.d[2, i, 0])
        #
        # Extension of cylinder
        #

        #self.g.add_node(15)
        self.npoints = 16

        pm  = (self.d[:, 9, 0] + self.d[:, 10, 0])/2.
        pmf = (self.d[:, 9, :] + self.d[:, 10, :])/2.
        pmf = pmf[:,np.newaxis,:]

        self.d = np.concatenate((self.d,pmf),axis=1)

        #self.g.add_edge(0, 15)
        self.g.pos[15] = (pm[1],pm[2])