aZhaoT commited on
Commit
a12075d
·
verified ·
1 Parent(s): 0630835

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +127 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ data_path = "./data/"
2
+
3
+ import pandas as pd
4
+
5
+ # load the csv into motion_capture_data
6
+
7
+ import streamlit as st
8
+ st.title("CyberOrigin Data Visualization")
9
+ dataset_option = st.sidebar.selectbox(
10
+ 'Select a dataset:',
11
+ ['Fold_towels', 'Pipette', 'Take_the_item', 'Twist_the_tube']
12
+ )
13
+ motion_capture_path = data_path+dataset_option +"/motionCaptureData.csv"
14
+ video_path = data_path+dataset_option+"/video.mp4"
15
+ motion_capture_data = pd.read_csv(motion_capture_path)
16
+ # create a streamlit app that displays the motion capture data
17
+ # and the video data
18
+ st.video(video_path)
19
+
20
+ body_part_names = ['Left Shoulder',
21
+ 'Right Upper Arm',
22
+ 'Left Lower Leg',
23
+ 'Spine1',
24
+ 'Right Upper Leg',
25
+ 'Spine3',
26
+ 'Right Lower Arm',
27
+ 'Left Foot',
28
+ 'Right Lower Leg',
29
+ 'Right Shoulder',
30
+ 'Left Hand',
31
+ 'Left Upper Leg',
32
+ 'Right Foot',
33
+ 'Spine',
34
+ 'Spine2',
35
+ 'Left Lower Arm',
36
+ 'Left Toe',
37
+ 'Neck',
38
+ 'Right Hand',
39
+ 'Right Toe',
40
+ 'Head',
41
+ 'Left Upper Arm',
42
+ 'Hips',]
43
+
44
+ motion_capture_x = motion_capture_data[[body_part_name+"_x" for body_part_name in body_part_names]]
45
+ motion_capture_y = motion_capture_data[[body_part_name+"_y" for body_part_name in body_part_names]]
46
+ motion_capture_z = motion_capture_data[[body_part_name+"_z" for body_part_name in body_part_names]]
47
+
48
+ import plotly.graph_objects as go
49
+ import numpy as np
50
+
51
+ # Sample Data Preparation
52
+ data = []
53
+ times = motion_capture_data["timestamp"]
54
+ frames = [go.Frame(
55
+ data=[
56
+ go.Scatter3d(
57
+ x=motion_capture_x.iloc[k],
58
+ y=motion_capture_y.iloc[k],
59
+ z=motion_capture_z.iloc[k],
60
+ mode='markers',
61
+ marker=dict(size=5, color='blue')
62
+ )
63
+ ],
64
+ name=str(k)
65
+ ) for k in range(len(times))]
66
+
67
+ # Create the initial scatter plot
68
+ initial_scatter = go.Scatter3d(
69
+ x=motion_capture_x.iloc[0],
70
+ y=motion_capture_y.iloc[0],
71
+ z=motion_capture_z.iloc[0],
72
+ mode='markers',
73
+ marker=dict(size=5, color='blue')
74
+ )
75
+
76
+ # Create the layout with slider
77
+ layout = go.Layout(
78
+ title='Motion Capture Visualization',
79
+ updatemenus=[{
80
+ 'buttons': [
81
+ {
82
+ 'args': [None, {'frame': {'duration': 1, 'redraw': True}, 'fromcurrent': True}],
83
+ 'label': 'Play',
84
+ 'method': 'animate'
85
+ },
86
+ {
87
+ 'args': [[None], {'frame': {'duration': 0, 'redraw': True}, 'mode': 'immediate', 'transition': {'duration': 0}}],
88
+ 'label': 'Pause',
89
+ 'method': 'animate'
90
+ }
91
+ ],
92
+ 'direction': 'left',
93
+ 'pad': {'r': 10, 't': 87},
94
+ 'showactive': True,
95
+ 'type': 'buttons',
96
+ 'x': 0.1,
97
+ 'xanchor': 'right',
98
+ 'y': 0,
99
+ 'yanchor': 'top'
100
+ }],
101
+ sliders=[{
102
+ 'active': 0,
103
+ 'steps': [{
104
+ 'label': str(k),
105
+ 'method': 'animate',
106
+ 'args': [
107
+ [str(k)],
108
+ {'mode': 'immediate', 'frame': {'duration': 300, 'redraw': True}, 'transition': {'duration': len(times)/30}}
109
+ ]
110
+ } for k in range(len(times))],
111
+ 'currentvalue': {
112
+ 'prefix': 'Time: ',
113
+ 'visible': True,
114
+ 'xanchor': 'right'
115
+ },
116
+ 'pad': {'b': 10},
117
+ 'len': 0.9,
118
+ 'x': 0.1,
119
+ 'y': 0,
120
+ }]
121
+ )
122
+
123
+ # Create the figure
124
+ fig = go.Figure(data=[initial_scatter], frames=frames, layout=layout)
125
+
126
+ # Display the figure in the streamlit app
127
+ st.plotly_chart(fig)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ plotly
4
+ numpy