-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_2D.py
More file actions
46 lines (35 loc) · 1.49 KB
/
example_2D.py
File metadata and controls
46 lines (35 loc) · 1.49 KB
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
import pandas as pd
import numpy as np
from FLK import FLK
from FLK import evaluate
import matplotlib.pyplot as plt
def main():
# Load the file
data = pd.read_csv("../openpose_valid.csv")
refined = data.copy()
# Keypoints number, name and order in the file
keypoints = ["LShoulder","RShoulder","LElbow ","RElbow ","LWrist ","RWrist","LHip ","RHip ","LKnee","RKnee","LAnkle","RAnkle"]
initialization_needed = True
for k in range(1,data.shape[0]): # ,143):#
skeleton = data.iloc[k,:].values[1:]
# If there are no keypoints detected go to the next frame
if np.all(np.isnan(skeleton)):
#refined.iloc[k,:].values[1:] = skeleton
initialization_needed = True
try: flk.reset()
except: pass
continue
# If it's the first time that a person come into the scene
if initialization_needed:
flk = FLK( fs=15, skeleton=skeleton, keypoints=keypoints, model_path=None ,\
latency=0, num_dimension=2, enable_bones=False, enable_lowpass_filter=True,
ema_filter_value=0.995)
flk.latency = 0
initialization_needed = False
continue
filtered_skeleton = flk.correct(skeleton)
refined.iloc[k,1:] = filtered_skeleton
flk.reset()
refined.to_csv("../test_flk.csv",na_rep='nan')
if __name__ == "__main__":
main()