Here the my output from my code
code’s output
There is a 33 keypoint, which consists of
body_pose = [‘NOSE’, ‘LEFT_EYE_INNER’, ‘LEFT_EYE’, ‘LEFT_EYE_OUTER’, ‘RIGHT_EYE_INNER’, ‘RIGHT_EYE’, ‘RIGHT_EYE_OUTER’, ‘LEFT_EAR’, ‘RIGHT_EAR’, ‘MOUTH_LEFT’, ‘MOUTH_RIGHT’,
‘LEFT_SHOULDER’, ‘RIGHT_SHOULDER’, ‘LEFT_ELBOW’, ‘RIGHT_ELBOW’, ‘LEFT_WRIST’, ‘RIGHT_WRIST’, ‘LEFT_PINKY’, ‘RIGHT_PINKY’, ‘LEFT_INDEX’, ‘RIGHT_INDEX’, ‘LEFT_THUMB’,
‘RIGHT_THUMB’, ‘LEFT_HIP’, ‘RIGHT_HIP’, ‘LEFT_KNEE’, ‘RIGHT_KNEE’, ‘LEFT_ANKLE’, ‘RIGHT_ANKLE’, ‘LEFT_HEEL’, ‘RIGHT_HEEL’, ‘LEFT_FOOT_INDEX’, ‘RIGHT_FOOT_INDEX’]
The problem is that the names NOSE_x, NOSE_y, and NOSE_z are stored on row 0 -> correct
But as for LEFT_EYE_INNER_x, LEFT_EYE_INNER_y, and LEFT_EYE_INNER_z are stored on row 1 -> wrong because they should be stored on row 0,and so on
how to combine it into one row?
Here, my code for append data and save it in excel format
` def save_data_to_excel(self):
data_dict = {pose_type: [] for pose_type in [‘pose’, ‘right_hand’, ‘left_hand’]}
for pose_type, pose_data in self.alldata:
for idx, (key, value) in enumerate(pose_data.items()):
# Append timestamp along with position data
timestamp = datetime.now().strftime(“%H:%M:%S.%f”)
key_suffix = [‘X’, ‘Y’, ‘Z’]
data_dict[pose_type].append({**{‘Number’: idx, ‘Timestamp’: timestamp}, **{f'{key}{key_suffix[i]}’: val for i, val in enumerate(value)}})
#data_row = [idx, timestamp] + [{f'{key}{key_suffix[i]}’: val for i, val in enumerate(value)}]
#data_dict[pose_type].append(data_row)
with pd.ExcelWriter('koordinat.xlsx') as writer:
for pose_type, data in data_dict.items():
df = pd.DataFrame(data)
df.to_excel(writer, sheet_name=pose_type, index=False)`
My expectation’s output is that the 33 keypoints and and timestamps divisible by 33 are stored at number 0, number 1, number 2, and so on in each one row
Johanes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.