-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
48 lines (40 loc) · 1.42 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os
import numpy as np
def getAllDataFilename(filepath):
allFile = []
for file in os.listdir(filepath):
if file.endswith(".txt"):
allFile.append(file)
return allFile
def getActionLabel(filename):
with open(filename, "r") as f:
action_labels = f.readlines()
action_labels = [int(x.strip()[1:3]) for x in action_labels]
return action_labels
def getActionSubject(filename):
with open(filename, "r") as f:
action_subjects = f.readlines()
action_subjects = [int(x.strip()[5:7]) for x in action_subjects]
return action_subjects
# sizeMatrix = N
# get index of upper Covariance Matrix
def getValueMatrix(sizeMatrix):
"""
:param sizeMatrix: size of matrix A (which represents all skeleton coordinators)
:return: half of covariance matrix indexes
"""
getMatrixIndex = np.zeros(0)
tmp = sizeMatrix
for i in range(sizeMatrix):
getMatrixIndex = np.append(getMatrixIndex, np.arange(tmp-sizeMatrix+i, tmp))
tmp += sizeMatrix
getMatrixIndex = getMatrixIndex.astype(np.uint8)
return getMatrixIndex
def getIdxMostJoints(matrixJoints, onf):
listAngle = np.unique(matrixJoints)
listValueAngle = np.zeros(listAngle.shape[0])
for i in range(listAngle.shape[0]):
listValueAngle[i] = np.sum(np.sum(matrixJoints == listAngle[i]))
ind = np.argsort(listValueAngle)
listIndex = ind[0:onf]
return listIndex