Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.22 KB | None | 0 0
  1. file = open("/home/ari/data/mfn/001.txt", 'r')
  2.  
  3. joints = {}
  4. last = 0
  5. for i in range(12):
  6.     joints[i] = {"index":[last,last+1,last+2], "frame_pos":{}}
  7.     last = last+3
  8.  
  9. for frame, o in enumerate(file.readlines()[:3]):
  10.     for index, sub_pos in enumerate(o.split()[1:]):
  11.         for jnt, indexes in joints.items():
  12.             if index in indexes["index"]:
  13.                 if not frame in joints[jnt]["frame_pos"].keys():
  14.                     joints[jnt]["frame_pos"][frame] = [sub_pos]
  15.                 else:
  16.                     joints[jnt]["frame_pos"][frame].append(sub_pos)
  17.                
  18. print (joints)
  19.  
  20. # Result: {0: {'frame_pos': {0: ['50.130943', '11.225624', '7.326612'],
  21.                    1: ['50.163795', '11.179263', '7.351764'],
  22.                    2: ['50.154865', '11.167265', '7.338380']},
  23.      'index': [0, 1, 2]},
  24.  1: {'frame_pos': {0: ['38.819107', '12.647936', '-20.346685'],
  25.                    1: ['38.698910', '12.433508', '-20.459576'],
  26.                    2: ['38.641900', '12.471968', '-20.604311']},
  27.      'index': [3, 4, 5]},
  28.  2: {'frame_pos': {0: ['40.370895', '8.603596', '-0.503769'],
  29.                    1: ['40.448270', '8.596457', '-0.589294'],
  30.                    2: ['40.811882', '8.609131', '-0.918249']},
  31.      'index': [6, 7, 8]},
  32.  3: {'frame_pos': {0: ['24.300209', '7.439987', '19.461359'],
  33.                    1: ['24.236298', '7.339370', '19.332895'],
  34.                    2: ['24.169746', '7.254933', '19.089020']},
  35.      'index': [9, 10, 11]},
  36.  4: {'frame_pos': {0: ['-1.449108', '3.244628', '10.998338'],
  37.                    1: ['-1.430230', '3.372107', '10.743616'],
  38.                    2: ['-1.474762', '3.406599', '10.497798']},
  39.      'index': [12, 13, 14]},
  40.  5: {'frame_pos': {0: ['61.053635', '9.280262', '-1.987783'],
  41.                    1: ['61.214638', '9.363702', '-1.761317'],
  42.                    2: ['61.336956', '9.414344', '-1.626783']},
  43.      'index': [15, 16, 17]},
  44.  6: {'frame_pos': {0: ['54.254340', '7.162307', '-17.192530'],
  45.                    1: ['54.177113', '7.186679', '-17.552835'],
  46.                    2: ['54.100605', '7.227420', '-17.906023']},
  47.      'index': [18, 19, 20]},
  48.  7: {'frame_pos': {0: ['39.989944', '34.497750', '-11.678810'],
  49.                    1: ['39.980130', '34.377640', '-11.782758'],
  50.                    2: ['39.955303', '34.382877', '-11.881460']},
  51.      'index': [21, 22, 23]},
  52.  8: {'frame_pos': {0: ['41.984905', '-20.735380', '-7.867349'],
  53.                    1: ['42.051506', '-20.623219', '-8.004448'],
  54.                    2: ['42.147446', '-20.485357', '-8.101501']},
  55.      'index': [24, 25, 26]},
  56.  9: {'frame_pos': {0: ['12.766768', '22.023468', '8.162199'],
  57.                    1: ['12.778726', '22.024857', '8.153212'],
  58.                    2: ['12.787201', '22.004467', '8.146826']},
  59.      'index': [27, 28, 29]},
  60.  10: {'frame_pos': {0: ['35.553432', '-1.448307', '5.000329'],
  61.                     1: ['35.518982', '-1.455337', '4.990771'],
  62.                     2: ['35.489230', '-1.465205', '4.996807']},
  63.       'index': [30, 31, 32]},
  64.  11: {'frame_pos': {0: ['33.846733', '18.936922', '2.715275'],
  65.                     1: ['33.757767', '18.966742', '2.729853'],
  66.                     2: ['33.763530', '18.942215', '2.703105']},
  67.       'index': [33, 34, 35]}} #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement