Skip to content

Commit

Permalink
加速度計算を追加してcalclistを更新、0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nishimura5 committed Dec 17, 2022
1 parent 38d0153 commit c30ee9f
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 32 deletions.
2 changes: 1 addition & 1 deletion BehavioralObservation_install.iss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "BehavioralObservation"
#define MyAppVersion "0.3.0.0"
#define MyAppVersion "0.4.0.0"
#define MyAppPublisher "EigoNishimura"
#define MyAppURL "https://github.com/nishimura5/VideoObservation"
#define MeventEditorName "MeventEditor.exe"
Expand Down
3 changes: 0 additions & 3 deletions Output/BehavioralObservation_0300.zip

This file was deleted.

3 changes: 0 additions & 3 deletions Output/BehavioralObservation_installer.exe

This file was deleted.

3 changes: 0 additions & 3 deletions Output/calclist_update.exe

This file was deleted.

3 changes: 0 additions & 3 deletions Output/calclist_update.zip

This file was deleted.

5 changes: 3 additions & 2 deletions trkproc/calclist/arms_pixel_body.calclist
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
;comment=左右腕(pixel)
;comment=左右の手の距離、左右の肘の距離(pixel)
pointA,pointB,func,legend,color
4,7,*1,右手-左手(4-7),#904f4f
3,6,*1,右肘-左肘(3-6),#4f904f
3,6,*1,右肘-左肘(3-6),#4f904f
2,5,*1,右肩-左肩(2-5),#75a150
4 changes: 2 additions & 2 deletions trkproc/calclist/directions_face.calclist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
;comment=頭部方向
;comment=頭部方向(Roll,Pitch,Yaw)
pointA,pointB,func,legend,color
roll,,*1,頭部(Roll),#904f4f
pitch,,*1,頭部(Pitch),#4f904f
yaw,,*1,頭部(Yaw),#4f4f90
yaw,,*1,頭部(Yaw),#4f4f90
9 changes: 9 additions & 0 deletions trkproc/calclist/neck_arms_a3_body.calclist
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;comment=首・手・肘・肩の加速度(3 frames delta)
pointA,pointB,func,legend,color
1,a3,*1,首(3f.),#904f4f
4,a3,*1,右手(3f.),#008080
7,a3,*1,左手(3f.),#ffa500
3,a3,*1,右肘(3f.),#75a150
6,a3,*1,左肘(3f.),#9045a1
2,a3,*1,右肩(3f.),#a17550
5,a3,*1,左肩(3f.),#4590a1
6 changes: 4 additions & 2 deletions trkproc/calclist/neck_arms_d30_body.calclist
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
;comment=首と腕(30 frames delta)
;comment=首・手・肘・肩の速さ(30 frames delta)
pointA,pointB,func,legend,color
1,d30,*1,首(30f.),#904f4f
4,d30,*1,右手(30f.),#008080
7,d30,*1,左手(30f.),#ffa500
3,d30,*1,右肘(30f.),#75a150
6,d30,*1,左肘(30f.),#9045a1
6,d30,*1,左肘(30f.),#9045a1
2,d30,*1,右肩(30f.),#a17550
5,d30,*1,左肩(30f.),#4590a1
8 changes: 6 additions & 2 deletions trkproc/calclist/neck_arms_d3_body.calclist
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
;comment=首と手(3 frames delta)
;comment=首・手・肘・肩の速さ(3 frames delta)
pointA,pointB,func,legend,color
1,d3,*1,首(3f.),#904f4f
4,d3,*1,右手(3f.),#008080
7,d3,*1,左手(3f.),#ffa500
7,d3,*1,左手(3f.),#ffa500
3,d3,*1,右肘(3f.),#75a150
6,d3,*1,左肘(3f.),#9045a1
2,d3,*1,右肩(3f.),#a17550
5,d3,*1,左肩(3f.),#4590a1
9 changes: 6 additions & 3 deletions trkproc/calclist/right_arm_body.calclist
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
;comment=右腕(x,y)
;comment=右手・右肘・右肩のxy座標
pointA,pointB,func,legend,color
3,x,*1,右肘x,#903f3f
3,y,*1,右肘y,#a07070
4,x,*1,右手x,#008080
4,y,*1,右手y,#3fbcbc
3,x,*1,右肘x,#903f3f
3,y,*1,右肘y,#a07070
2,x,*1,右肩x,#a17550
2,y,*1,右肩y,#4590a1

2 changes: 1 addition & 1 deletion trkproc/calclist/right_leg_body.calclist
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;comment=右脚(x,y)
;comment=右足と右膝のxy座標
pointA,pointB,func,legend,color
10,x,*1,右膝x,#903f3f
10,y,*1,右膝y,#a07070
Expand Down
4 changes: 2 additions & 2 deletions trkproc/calclist/waist_legs_d30_body.calclist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
;comment=腰と脚(30 frames delta)
;comment=腰・足・膝の速さ(30 frames delta)
pointA,pointB,func,legend,color
8,d30,*1,腰(30f.),#904f4f
11,d30,*1,右足(30f.),#008080
14,d30,*1,左足(30f.),#ffa500
10,d30,*1,右膝(30f.),#75a150
13,d30,*1,左膝(30f.),#9045a1
13,d30,*1,左膝(30f.),#9045a1
7 changes: 6 additions & 1 deletion trkproc/lineplot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys,os
import traceback
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

import pandas as pd
Expand Down Expand Up @@ -90,7 +91,7 @@ def plot_lines(self, ylim=None, zero_line=True, tick_interval_sec=30):
print('%d [%s] %s' % (i, name, line))
ax.plot(self.time_arr, self.data_df.loc[pd.IndexSlice[:,name], line['points']].to_numpy(), color=line['color'], linewidth=0.5, label=line['legend'])
except Exception as e:
logger.error(e)
logger.error(self._traceback_parser(e))
logger.error('self.data_df={}'.format(self.data_df))
# logger.error('self.time_arr={}'.format(self.time_arr))
raise Exception(e)
Expand Down Expand Up @@ -194,6 +195,10 @@ def __fill(self):
print(self.data_df)
print(dummy_df)

def _traceback_parser(self, e):
line = traceback.format_tb(e.__traceback__)[0].split(', ')[1]
return '{},{}'.format(line, e)

def close(self):
plt.close()

Expand Down
4 changes: 4 additions & 0 deletions trkproc/op_point_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ def load_calclist(self, calclist_path):
elif row.pointB[0] == 'd':
tar_df = self.calc_diff(row.pointA, int(row.pointB[1:]))
col_name = row.pointA+'_diff'
## pointBの先頭がa = 移動量の変位量(aの次がstepのフレーム数)
elif row.pointB[0] == 'a':
tar_df = self.calc_diffdiff(row.pointA, int(row.pointB[1:]))
col_name = row.pointA+'_diffdiff'
## それ以外 = 距離
else:
col_name = '{}-{}'.format(row.pointA, row.pointB)
Expand Down
17 changes: 13 additions & 4 deletions trkproc/point_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,25 +96,34 @@ def calc_point2point(self, point1, point2, new_column_name='distance'):
return dist_df

## フレーム間の移動量を計算
def calc_diff(self, point_code, step):
def calc_diff(self, point_code, step, suffix='diff'):
try:
diff_df = self.tar_trk_df.loc[pd.IndexSlice[:,:,point_code], :]
diff_df = diff_df.groupby(['name']).diff(step)**2
# diff_df = pd.DataFrame(np.sqrt(diff_df['x'] + diff_df['y'])).set_index(['frame','name']).drop('code', axis=1)
diff_df = pd.DataFrame({'{}_diff'.format(point_code):(np.sqrt(diff_df['x'] + diff_df['y']))})
diff_df = pd.DataFrame({f'{point_code}_{suffix}':(np.sqrt(diff_df['x'] + diff_df['y']))})
diff_df = diff_df.reset_index(['code'], drop=True)

except Exception as e:
logger.error(self._traceback_parser(e))
raise Exception(e)
return diff_df

def calc_diffdiff(self, point_code, step):
try:
diff_df = self.calc_diff(point_code, step, suffix='diffdiff')
diffdiff_df = diff_df.groupby(['name']).diff(step)
except Exception as e:
logger.error(self._traceback_parser(e))
raise Exception(e)
return diffdiff_df

def get_point(self, point_code, new_column_name=None):
tar_df = self.trk_df.loc[pd.IndexSlice[:,:,point_code],:].reset_index().set_index(['frame','name']).drop('code', axis=1)
if new_column_name is None:
tar_df = tar_df.rename(columns={'x':'%s_x'%point_code, 'y':'%s_y'%point_code})
tar_df = tar_df.rename(columns={'x':f"{point_code}_x", 'y':f"{point_code}_y"})
else:
tar_df = tar_df.rename(columns={'x':'%s_x'%new_column_name, 'y':'%s_y'%new_column_name})
tar_df = tar_df.rename(columns={'x':f"{new_column_name}_x", 'y':f"{new_column_name}_y"})
return tar_df

## 外積
Expand Down

0 comments on commit c30ee9f

Please sign in to comment.