-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
51 lines (41 loc) · 1.61 KB
/
test.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
48
49
50
51
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render
from django.views.decorators.csrf import csrf_exempt
from sklearn.decomposition import PCA
import subprocess
import pandas as pd
import matplotlib.pyplot as plt
# Create your views here.
featureExtractionPath = "/Users/ashish/Desktop/OpenFace/OpenFace/build/bin/FeatureExtraction"
openFacePath = "someTempPath"
@csrf_exempt
def runOpenFace(videoPath, videoName):
res = subprocess.check_output([featureExtractionPath, '-f', '/Users/ashish/Downloads/videoplayback.mp4'])
for line in res.splitlines():
print(line)
processedOpenFacePath = "/Users/ashish/Desktop/processed/videoplayback.csv"
df = pd.read_csv(processedOpenFacePath)
print(df)
df_json = df.to_json('temp.json', orient='records', lines=True)
pca = PCA(n_components=2)
principalComponents = pca.fit_transform(df)
principalDf = pd.DataFrame(data = principalComponents, columns = ['principal component 1', 'principal component 2'])
fig = plt.figure(figsize = (8,8))
ax = fig.add_subplot(1,1,1)
ax.set_xlabel('Principal Component 1', fontsize = 15)
ax.set_ylabel('Principal Component 2', fontsize = 15)
ax.set_title('OpenFace Visualization', fontsize = 20)
targets = ['OpenFace']
ax.scatter(principalDf.loc[:,'principal component 1'] , principalDf.loc[:, 'principal component 2'] , c = 'r' , s = 50)
ax.legend(targets)
ax.grid()
plt.show()
#file = open("testfile.text", "w")
#file.write(df_json)
#file.close()
return
@csrf_exempt
def runOpenPose(request):
return
runOpenFace("","")