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