资源简介
动作识别
训练
python ActionRecognition/train_action_from_pose.py
测试
通过getpersonpose_array获取信息,然后运行
python ActionRecognition/test_action_from_pose.py
其中,person02_boxing_d2_uncomp 和 person05_walking_d1_uncomp 需要预先通过 PosturalRecognition/test/VideoCapture.py 进行预处理
最后输出动作发生的概率
代码片段和文件信息
import numpy as np
def u(D k x mu sigma):
a = x - mu[k]
b = 0
for x in a:
b += x ** 2
c = 2 * sigma[k]
d = np.power(2 * np.pi float(D) / 2)
e = np.sqrt(np.abs(sigma[k]))
return np.exp((b / c) / (d * e))
def computeGamma(D t k K omega mu sigma):
sum = 0
for i in range(K):
sum += omega[i] * u(D i X[t] mu sigma)
return (omega[k] * u(D k X[t] mu sigma)) / sum
def computeStatistics(K T D S X omega mu sigma):
for k in range(K):
S[k][0] = 0
S[k][1] = np.zeros(D)
S[k][2] = np.zeros(D)
for t in range(T):
for k in range(K):
gamma = computeGamma(D t k K omega mu sigma)
S[k][0] = S[k][0] + gamma
S[k][1] = S[k][1] + gamma * X[t]
S[k][2] = S[k][2] + gamma * X[t] * X[t]
return S
def computeFisherVectorSignature(K T D S X omega mu sigma):
F_alpha = [S[0][0] for _ in range(K)]
F_mu = [S[0][1] for _ in range(K)]
F_sigma = [S[0][2] for _ in range(K)]
for k in range(K):
F_alpha[k] = (S[k][0] - T * omega[k]) / np.sqrt(omega[k])
F_mu[k] = (S[k][1] - mu[k] * S[k][0]) / (np.sqrt(omega[k]) * sigma[k])
F_sigma[k] = (S[k][2] - 2 * mu[k] * S[k][1] + (np.power(mu[k] 2) - np.power(sigma[k] 2)) * S[k][0]) / (
np.sqrt(2 * omega[k]) * np.power(sigma[k] 2))
return F_alpha F_mu F_sigma
def applyNormalizations(F):
“““
归一化
:param F: Fisher向量
:return: 归一化后的Fisher向量
“““
F_alpha = F[0]
F_mu = F[1]
F_sigma = F[2]
sum = 0
for i in range(len(F_alpha)):
F_alpha[i] = np.sqrt(np.abs(F_alpha[i])) * np.sign(F_alpha[i])
sum += F_alpha[i] ** 2
F_alpha = F_alpha / np.sqrt(sum)
for i in range(len(F_mu)):
F_mu[i] = np.sqrt(np.abs(F_mu[i])) * np.sign(F_mu[i])
sqr = F_mu[i] ** 2
sum = 0
for s in sqr:
sum += s
F_mu[i] = F_mu[i] / np.sqrt(sum)
for i in range(len(F_sigma)):
F_sigma[i] = np.sqrt(np.abs(F_sigma[i])) * np.sign(F_sigma[i])
sqr = F_sigma[i] ** 2
sum = 0
for s in sqr:
sum += s
F_sigma[i] = F_sigma[i] / np.sqrt(sum)
return F_alpha F_mu F_sigma
def transposeFv(F):
“““
转置并重新排列
:param F: Fisher向量
:return: F_alpha F_mu F_sigma,均为一维向量
“““
F_alpha = F[0]
F_mu = F[1]
F_sigma = F[2]
tmp = []
for f in F_alpha:
tmp.append(f)
F_alpha = np.array(tmp)
tmp = []
for k in F_mu:
for d in k:
tmp.append(d)
F_mu = np.array(tmp)
tmp = []
for k in F_sigma:
for d in k:
tmp.append(d)
F_sigma = np.array(tmp)
return F_alpha F_mu F_sigma
def computeFisherVector(X omega mu sigma):
“““
计算Fisher向量
:param X: 数据点,维数为D
:param omega: 每个部分的权重,总和为1
:param mu: 每个部分的平均值
:param sigma: 每个部分的方差
:return: alpha mu sigma对应的Fisher向量
“
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-04-02 01:12 MPPE-master\
目录 0 2018-04-02 01:12 MPPE-master\.idea\
文件 554 2018-04-02 01:12 MPPE-master\.idea\MPPE.iml
目录 0 2018-04-02 01:12 MPPE-master\.idea\inspectionProfiles\
文件 817 2018-04-02 01:12 MPPE-master\.idea\inspectionProfiles\Project_Default.xm
文件 406 2018-04-02 01:12 MPPE-master\.idea\misc.xm
文件 260 2018-04-02 01:12 MPPE-master\.idea\modules.xm
文件 233 2018-04-02 01:12 MPPE-master\.idea\other.xm
目录 0 2018-04-02 01:12 MPPE-master\ActionRecognition\
目录 0 2018-04-02 01:12 MPPE-master\ActionRecognition\Actions\
文件 1608389 2018-04-02 01:12 MPPE-master\ActionRecognition\Actions\boxing.m
文件 4334 2018-04-02 01:12 MPPE-master\ActionRecognition\FisherVector.py
文件 2706 2018-04-02 01:12 MPPE-master\ActionRecognition\GMM.py
文件 3039 2018-04-02 01:12 MPPE-master\ActionRecognition\test_action_from_pose.py
文件 1340 2018-04-02 01:12 MPPE-master\ActionRecognition\tmp.py
文件 1848 2018-04-02 01:12 MPPE-master\ActionRecognition\train_action_from_pose.py
目录 0 2018-04-02 01:12 MPPE-master\PosturalRecognition\
目录 0 2018-04-02 01:12 MPPE-master\PosturalRecognition\models\
文件 8609 2018-04-02 01:12 MPPE-master\PosturalRecognition\models\FaceNet.py
文件 8602 2018-04-02 01:12 MPPE-master\PosturalRecognition\models\HandNet.py
文件 15374 2018-04-02 01:12 MPPE-master\PosturalRecognition\models\PoseNet.py
文件 0 2018-04-02 01:12 MPPE-master\PosturalRecognition\models\__init__.py
文件 674605 2018-04-02 01:12 MPPE-master\PosturalRecognition\models\haarcascade_frontalface_alt.xm
文件 690 2018-04-02 01:12 MPPE-master\PosturalRecognition\plot_train_log.py
目录 0 2018-04-02 01:12 MPPE-master\PosturalRecognition\test\
文件 4093 2018-04-02 01:12 MPPE-master\PosturalRecognition\test\VideoCapture.py
文件 0 2018-04-02 01:12 MPPE-master\PosturalRecognition\test\__init__.py
文件 2315 2018-04-02 01:12 MPPE-master\PosturalRecognition\test\camera_face.py
文件 1770 2018-04-02 01:12 MPPE-master\PosturalRecognition\test\camera_pose.py
文件 7036 2018-04-02 01:12 MPPE-master\PosturalRecognition\test\get_person_pose_array.py
文件 2937 2018-04-02 01:12 MPPE-master\PosturalRecognition\test\save_npy.py
............此处省略43个文件信息
评论
共有 条评论