def BodyData(p_id): # Load the performance Data with Database(DATABASE) as db: table = JOINT_DATA_TABLE, BODY_TIME_TABLE, BODY_NAME_TABLE # Load the co-ordinates and frame timestamps data = db.query(JOINT_DATA_TABLE, p_id) time = db.query(BODY_TIME_TABLE, p_id) # Load any custom name labels for the bodies role = [r[0] for r in db.query(BODY_NAME_TABLE, p_id, columns=("name",))] # Convert time to a dict time = dict([(row['frame'], row['time']) for row in time]) num_bodies = max([row['body'] for row in data]) + 1 bodies = [Skeleton.Body(name=(role[n] if n < len(role) else n)) for n in range(num_bodies)] for row in data: body = bodies[row['body']] joint = body[row['joint_id']] # Assign 3D co-ordinates (m) in 2dp joint[row['frame']] = [f for f in (row['x'], row['y'], row['z'])] # Add 2D co-ordinates (px) joint.add(row['frame'], row['pixel_x'], row['pixel_y']) # Get the real time values and add to BODY object body.frame_time(row['frame'], time[row['frame']]) return bodies