Skip to content

Free Motion Capture for Everyone πŸ’€βœ¨

TypeScript

Jon/npy to csv ipynb (#234)

jonmatthis03698d93f02d
diff --git a/assets/logo/freemocap_skelly_logo.ico b/assets/logo/freemocap_skelly_logo.ico
new file mode 100644
index 00000000..64beb58a
Binary files /dev/null and b/assets/logo/freemocap_skelly_logo.ico differ
diff --git a/ipython_jupyter_notebooks/export_freemocap_npy_as_pandas_data_frame_csv.ipynb b/ipython_jupyter_notebooks/export_freemocap_npy_as_pandas_data_frame_csv.ipynb
new file mode 100644
index 00000000..3babc4e9
--- /dev/null
+++ b/ipython_jupyter_notebooks/export_freemocap_npy_as_pandas_data_frame_csv.ipynb
@@ -0,0 +1,516 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": false,
+ "pycharm": {
+ "name": "#%% md\n"
+ }
+ },
+ "source": [
+ "\n",
+ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/freemocap/freemocap/blob/jon%2Fnpy_to_csv_ipynb/ipython_jupyter_notebooks/export_freemocap_npy_as_pandas_data_frame_csv.ipynb#scrollTo=xVLt0acPoAks]\n",
+ "\n",
+ "# convert standard `freemocap` `npy` output to `pandas.DataFrame` `csv` files\n",
+ "\n",
+ "## HOW TO USE\n",
+ " change the `mediapipe_3d_npy_path` entry down there to the path to the `mediapipe_3d_whatever.npy` file from the session you want to convert\n",
+ " this notebook will:\n",
+ " - save out individual `npy` files for the `body`, `hands` and `face` data\n",
+ " - 'tracked_points' aka 'landmarks' are in the 2nd dimension and follow the order listed here:\n",
+ " - body - https://google.github.io/mediapipe/solutions/pose.html#pose-landmark-model-blazepose-ghum-3d\n",
+ " - hands - https://google.github.io/mediapipe/solutions/hands.html#hand-landmark-model\n",
+ " - face - need to do some work to get that order in any kind of useable state\n",
+ " - save out individual `csv` files for the `body`, `hands` and `face` data (based on Pandas.DataFrame) with named columns showing the name of the `tracked_points`\n",
+ "\n",
+ "\n",
+ "- [ x ] load in `mediapipe_3d` data from a `freemocap` session\n",
+ "- [ x ] get tracked_point names from `mediapipe`\n",
+ "- [ x ] Create `pandas.DataFrame` objects for:\n",
+ " - [ / ] body_data\n",
+ " - [ x ] xyz data\n",
+ " - [ ] reprojection_error data\n",
+ " - [ x ] right_hand_data\n",
+ " - [ x ] left_hand_data\n",
+ " - [ / ] face_data\n",
+ " - [ x ] face mesh data (i.e. all data points)\n",
+ " - [ ] face contour data (i.e. only the 'contour' parts of the face"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {
+ "collapsed": false,
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "from pathlib import Path\n",
+ "import pandas as pd\n",
+ "import numpy as np\n",
+ "from mediapipe.python.solutions import holistic as mp_holistic"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "outputs": [],
+ "source": [
+ "# Path to the `npy` file containing the `medipipe3d` data for the `freemocap` session you want to export\n",
+ "mediapipe_3d_npy_path = Path(r\"C:\\Users\\jonma\\freemocap_data\\session_07-26-2022-08_07_30\\output_data_files\\mediapipe_3dData_numFrames_numTrackedPoints_spatialXYZ.npy\") #path to the relevant `mediapipe_3d.npy` file\n"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ }
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "outputs": [],
+ "source": [
+ "\n",
+ "\n",
+ "mediapipe_3d_frame_trackedPoint_xyz = np.load(str(mediapipe_3d_npy_path))\n",
+ "\n",
+ "print(f'loaded npy data with shape: {mediapipe_3d_frame_trackedPoint_xyz.shape}')\n"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ }
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "outputs": [],
+ "source": [
+ "pose_landmark_names = [landmark.name.lower() for landmark in mp_holistic.PoseLandmark]\n",
+ "hand_landmark_names = [landmark.name.lower() for landmark in mp_holistic.HandLandmark]\n",
+ "# face_landmark_names = [landmark.name.lower() for landmark in mp_holistic.PoseLandmark] #gonna have the clever for the face\n",
+ "print(f\"Body tracked point names: {pose_landmark_names}\")\n",
+ "print(hand_landmark_names)"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ }
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "outputs": [],
+ "source": [
+ "#get number of points in body, hands, face\n",
+ "\n",
+ "number_of_body_points = len(pose_landmark_names)\n",
+ "number_of_hand_points = len(hand_landmark_names)\n",
+ "\n",
+ "first_body_marker_index = 0\n",
+ "last_body_marker_index = number_of_body_points-1\n",
+ "\n",
+ "first_right_hand_marker_index = last_body_marker_index + 1\n",
+ "last_right_hand_marker_index = number_of_body_points + number_of_hand_points-1\n",
+ "\n",
+ "first_left_hand_marker_index = last_right_hand_marker_index + 1\n",
+ "last_left_hand_marker_index = last_right_hand_marker_index+1 + number_of_hand_points-1\n",
+ "\n",
+ "first_face_marker_index = last_left_hand_marker_index + 1\n",
+ "last_face_marker_index = mediapipe_3d_frame_trackedPoint_xyz.shape[1]\n",
+ "\n",
+ "number_of_face_points = last_face_marker_index - first_face_marker_index\n",
+ "\n",
+ "print(f\"body tracked point indices: {first_body_marker_index}:{last_body_marker_index}\")\n",
+ "print(f\"right hand tracked point indices: {first_right_hand_marker_index}:{last_right_hand_marker_index}\")\n",
+ "print(f\"left hand tracked point indices: {first_left_hand_marker_index}:{last_left_hand_marker_index}\")\n",
+ "print(f\"face tracked point indices: {first_face_marker_index}:{last_face_marker_index}\")\n",
+ "\n",
+ "print(f\"number of body points: {last_body_marker_index-first_body_marker_index+1}\")\n",
+ "print(f\"number of right hand points: {last_right_hand_marker_index-first_right_hand_marker_index+1}\")\n",
+ "print(f\"number of left hand points: {last_left_hand_marker_index-first_left_hand_marker_index+1}\")\n",
+ "print(f\"number of face points: {last_face_marker_index-first_face_marker_index+1}\")\n",
+ "\n"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ }
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "outputs": [],
+ "source": [
+ "body_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[:,first_body_marker_index:last_body_marker_index+1,:]\n",
+ "right_hand_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[:,first_right_hand_marker_index:last_right_hand_marker_index+1,:]\n",
+ "left_hand_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[:,first_left_hand_marker_index:last_left_hand_marker_index+1,:]\n",
+ "face_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[:,first_face_marker_index:last_face_marker_index+1,:]\n",
+ "\n",
+ "print(f\"body 3d xyz shape: {body_3d_xyz.shape}\")\n",
+ "print(f\"right hand 3d xyz shape: {right_hand_3d_xyz.shape}\")\n",
+ "print(f\"left hand 3d xyz shape: {left_hand_3d_xyz.shape}\")\n",
+ "print(f\"face 3d xyz shape: {face_3d_xyz.shape}\")"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ }
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "outputs": [],
+ "source": [
+ "# save broken up npy files\n",
+ "np.save(str(mediapipe_3d_npy_path.parent / \"mediapipe_body_3d_xyz.npy\"), body_3d_xyz)\n",
+ "np.save(str(mediapipe_3d_npy_path.parent / \"mediapipe_right_hand_3d_xyz.npy\"), right_hand_3d_xyz)\n",
+ "np.save(str(mediapipe_3d_npy_path.parent / \"mediapipe_left_hand_3d_xyz.npy\"), left_hand_3d_xyz)\n",
+ "np.save(str(mediapipe_3d_npy_path.parent / \"mediapipe_face_3d_xyz.npy\"), face_3d_xyz)"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ }
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "outputs": [],
+ "source": [
+ "# create pandas data frame headers\n",
+ "\n",
+ "body_3d_xyz_header = []\n",
+ "for landmark_name in pose_landmark_names:\n",
+ " body_3d_xyz_header.append(f\"{landmark_name}_x\")\n",
+ " body_3d_xyz_header.append(f\"{landmark_name}_y\")\n",
+ " body_3d_xyz_header.append(f\"{landmark_name}_z\")\n",
+ "\n",
+ "right_hand_3d_xyz_header = []\n",
+ "for landmark_name in hand_landmark_names:\n",
+ " right_hand_3d_xyz_header.append(f\"right_hand_{landmark_name}_x\")\n",
+ " right_hand_3d_xyz_header.append(f\"right_hand_{landmark_name}_y\")\n",
+ " right_hand_3d_xyz_header.append(f\"right_hand_{landmark_name}_z\")\n",
+ "\n",
+ "left_hand_3d_xyz_header = []\n",
+ "for landmark_name in hand_landmark_names:\n",
+ " left_hand_3d_xyz_header.append(f\"left_hand_{landmark_name}_x\")\n",
+ " left_hand_3d_xyz_header.append(f\"left_hand_{landmark_name}_y\")\n",
+ " left_hand_3d_xyz_header.append(f\"left_hand_{landmark_name}_z\")\n",
+ "\n",
+ "face_3d_xyz_header = []\n",
+ "for landmark_number in range(last_face_marker_index - first_face_marker_index):\n",
+ " face_3d_xyz_header.append(f\"face_{str(landmark_number).zfill(4)}_x\")\n",
+ " face_3d_xyz_header.append(f\"face_{str(landmark_number).zfill(4)}_y\")\n",
+ " face_3d_xyz_header.append(f\"face_{str(landmark_number).zfill(4)}_z\")\n",
+ "\n",
+ "# print(f\"body 3d xyz header: {body_3d_xyz_header}\")\n",
+ "# print(f\"right hand 3d xyz header: {right_hand_3d_xyz_header}\")\n",
+ "# print(f\"left hand 3d xyz header: {left_hand_3d_xyz_header}\")\n",
+ "# print(f\"face 3d xyz header: {face_3d_xyz_header}\")\n",
+ "\n",
+ "print(f\"length of body 3d xyz header: {len(body_3d_xyz_header)}, should be: {number_of_body_points*3}\")\n",
+ "print(f\"length of right hand 3d xyz header: {len(right_hand_3d_xyz_header)}, should be: {number_of_hand_points*3}\")\n",
+ "print(f\"length of left hand 3d xyz header: {len(left_hand_3d_xyz_header)}, should be: {number_of_hand_points*3}\")\n",
+ "print(f\"length of face 3d xyz header: {len(face_3d_xyz_header)}, should be: {number_of_face_points*3}\")"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ }
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "outputs": [],
+ "source": [
+ "number_of_frames = mediapipe_3d_frame_trackedPoint_xyz.shape[0]\n",
+ "body_flat = body_3d_xyz.reshape(number_of_frames, number_of_body_points*3)\n",
+ "body_flat.shape\n",
+ "\n",
+ "body_dataframe = pd.DataFrame(body_flat, columns=body_3d_xyz_header)\n",
+ "body_dataframe.to_csv(str(mediapipe_3d_npy_path.parent / \"mediapipe_body_3d_xyz.csv\"), index=False)\n",
+ "\n",
+ "right_hand_flat = right_hand_3d_xyz.reshape(number_of_frames, number_of_hand_points*3)\n",
+ "right_hand_dataframe = pd.DataFrame(right_hand_flat, columns=right_hand_3d_xyz_header)\n",
+ "right_hand_dataframe.to_csv(str(mediapipe_3d_npy_path.parent / \"mediapipe_right_hand_3d_xyz.csv\"), index=False)\n",
+ "\n",
+ "left_hand_flat = left_hand_3d_xyz.reshape(number_of_frames, number_of_hand_points*3)\n",
+ "left_hand_dataframe = pd.DataFrame(left_hand_flat, columns=left_hand_3d_xyz_header)\n",
+ "left_hand_dataframe.to_csv(str(mediapipe_3d_npy_path.parent / \"mediapipe_left_hand_3d_xyz.csv\"), index=False)\n",
+ "\n",
+ "face_flat = face_3d_xyz.reshape(number_of_frames, number_of_face_points*3)\n",
+ "face_dataframe = pd.DataFrame(face_flat, columns=face_3d_xyz_header)\n",
+ "face_dataframe.to_csv(str(mediapipe_3d_npy_path.parent / \"mediapipe_face_3d_xyz.csv\"), index=False)\n"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ }
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "outputs": [],
+ "source": [],
+ "metadata": {
+ "collapsed": false,
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ }
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {
+ "collapsed": false,
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Body tracked point names: ['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']\n",
+ "['wrist', 'thumb_cmc', 'thumb_mcp', 'thumb_ip', 'thumb_tip', 'index_finger_mcp', 'index_finger_pip', 'index_finger_dip', 'index_finger_tip', 'middle_finger_mcp', 'middle_finger_pip', 'middle_finger_dip', 'middle_finger_tip', 'ring_finger_mcp', 'ring_finger_pip', 'ring_finger_dip', 'ring_finger_tip', 'pinky_mcp', 'pinky_pip', 'pinky_dip', 'pinky_tip']\n"
+ ]
+ }
+ ],
+ "source": [
+ "pose_landmark_names = [landmark.name.lower() for landmark in mp_holistic.PoseLandmark]\n",
+ "hand_landmark_names = [landmark.name.lower() for landmark in mp_holistic.HandLandmark]\n",
+ "# face_landmark_names = [landmark.name.lower() for landmark in mp_holistic.PoseLandmark] #gonna have the clever for the face\n",
+ "print(f\"Body tracked point names: {pose_landmark_names}\")\n",
+ "print(hand_landmark_names)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "body tracked point indices: 0:32\n",
+ "right hand tracked point indices: 33:53\n",
+ "left hand tracked point indices: 54:74\n",
+ "face tracked point indices: 75:553\n",
+ "number of body points: 33\n",
+ "number of right hand points: 21\n",
+ "number of left hand points: 21\n",
+ "number of face points: 479\n"
+ ]
+ }
+ ],
+ "source": [
+ "#get number of points in body, hands, face\n",
+ "\n",
+ "number_of_body_points = len(pose_landmark_names)\n",
+ "number_of_hand_points = len(hand_landmark_names)\n",
+ "\n",
+ "first_body_marker_index = 0\n",
+ "last_body_marker_index = number_of_body_points-1\n",
+ "\n",
+ "first_right_hand_marker_index = last_body_marker_index + 1\n",
+ "last_right_hand_marker_index = number_of_body_points + number_of_hand_points-1\n",
+ "\n",
+ "first_left_hand_marker_index = last_right_hand_marker_index + 1\n",
+ "last_left_hand_marker_index = last_right_hand_marker_index+1 + number_of_hand_points-1\n",
+ "\n",
+ "first_face_marker_index = last_left_hand_marker_index + 1\n",
+ "last_face_marker_index = mediapipe_3d_frame_trackedPoint_xyz.shape[1]\n",
+ "\n",
+ "number_of_face_points = last_face_marker_index - first_face_marker_index\n",
+ "\n",
+ "print(f\"body tracked point indices: {first_body_marker_index}:{last_body_marker_index}\")\n",
+ "print(f\"right hand tracked point indices: {first_right_hand_marker_index}:{last_right_hand_marker_index}\")\n",
+ "print(f\"left hand tracked point indices: {first_left_hand_marker_index}:{last_left_hand_marker_index}\")\n",
+ "print(f\"face tracked point indices: {first_face_marker_index}:{last_face_marker_index}\")\n",
+ "\n",
+ "print(f\"number of body points: {last_body_marker_index-first_body_marker_index+1}\")\n",
+ "print(f\"number of right hand points: {last_right_hand_marker_index-first_right_hand_marker_index+1}\")\n",
+ "print(f\"number of left hand points: {last_left_hand_marker_index-first_left_hand_marker_index+1}\")\n",
+ "print(f\"number of face points: {last_face_marker_index-first_face_marker_index+1}\")\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "body 3d xyz shape: (375, 33, 3)\n",
+ "right hand 3d xyz shape: (375, 21, 3)\n",
+ "left hand 3d xyz shape: (375, 21, 3)\n",
+ "face 3d xyz shape: (375, 478, 3)\n"
+ ]
+ }
+ ],
+ "source": [
+ "body_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[:,first_body_marker_index:last_body_marker_index+1,:]\n",
+ "right_hand_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[:,first_right_hand_marker_index:last_right_hand_marker_index+1,:]\n",
+ "left_hand_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[:,first_left_hand_marker_index:last_left_hand_marker_index+1,:]\n",
+ "face_3d_xyz = mediapipe_3d_frame_trackedPoint_xyz[:,first_face_marker_index:last_face_marker_index+1,:]\n",
+ "\n",
+ "print(f\"body 3d xyz shape: {body_3d_xyz.shape}\")\n",
+ "print(f\"right hand 3d xyz shape: {right_hand_3d_xyz.shape}\")\n",
+ "print(f\"left hand 3d xyz shape: {left_hand_3d_xyz.shape}\")\n",
+ "print(f\"face 3d xyz shape: {face_3d_xyz.shape}\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 31,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# save broken up npy files\n",
+ "np.save(str(mediapipe_3d_npy_path.parent / \"mediapipe_body_3d_xyz.npy\"), body_3d_xyz)\n",
+ "np.save(str(mediapipe_3d_npy_path.parent / \"mediapipe_right_hand_3d_xyz.npy\"), right_hand_3d_xyz)\n",
+ "np.save(str(mediapipe_3d_npy_path.parent / \"mediapipe_left_hand_3d_xyz.npy\"), left_hand_3d_xyz)\n",
+ "np.save(str(mediapipe_3d_npy_path.parent / \"mediapipe_face_3d_xyz.npy\"), face_3d_xyz)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 32,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "length of body 3d xyz header: 99, should be: 99\n",
+ "length of right hand 3d xyz header: 63, should be: 63\n",
+ "length of left hand 3d xyz header: 63, should be: 63\n",
+ "length of face 3d xyz header: 1434, should be: 1434\n"
+ ]
+ }
+ ],
+ "source": [
+ "# create pandas data frame headers\n",
+ "\n",
+ "body_3d_xyz_header = []\n",
+ "for landmark_name in pose_landmark_names:\n",
+ " body_3d_xyz_header.append(f\"{landmark_name}_x\")\n",
+ " body_3d_xyz_header.append(f\"{landmark_name}_y\")\n",
+ " body_3d_xyz_header.append(f\"{landmark_name}_z\")\n",
+ "\n",
+ "right_hand_3d_xyz_header = []\n",
+ "for landmark_name in hand_landmark_names:\n",
+ " right_hand_3d_xyz_header.append(f\"right_hand_{landmark_name}_x\")\n",
+ " right_hand_3d_xyz_header.append(f\"right_hand_{landmark_name}_y\")\n",
+ " right_hand_3d_xyz_header.append(f\"right_hand_{landmark_name}_z\")\n",
+ "\n",
+ "left_hand_3d_xyz_header = []\n",
+ "for landmark_name in hand_landmark_names:\n",
+ " left_hand_3d_xyz_header.append(f\"left_hand_{landmark_name}_x\")\n",
+ " left_hand_3d_xyz_header.append(f\"left_hand_{landmark_name}_y\")\n",
+ " left_hand_3d_xyz_header.append(f\"left_hand_{landmark_name}_z\")\n",
+ "\n",
+ "face_3d_xyz_header = []\n",
+ "for landmark_number in range(last_face_marker_index - first_face_marker_index):\n",
+ " face_3d_xyz_header.append(f\"face_{str(landmark_number).zfill(4)}_x\")\n",
+ " face_3d_xyz_header.append(f\"face_{str(landmark_number).zfill(4)}_y\")\n",
+ " face_3d_xyz_header.append(f\"face_{str(landmark_number).zfill(4)}_z\")\n",
+ "\n",
+ "# print(f\"body 3d xyz header: {body_3d_xyz_header}\")\n",
+ "# print(f\"right hand 3d xyz header: {right_hand_3d_xyz_header}\")\n",
+ "# print(f\"left hand 3d xyz header: {left_hand_3d_xyz_header}\")\n",
+ "# print(f\"face 3d xyz header: {face_3d_xyz_header}\")\n",
+ "\n",
+ "print(f\"length of body 3d xyz header: {len(body_3d_xyz_header)}, should be: {number_of_body_points*3}\")\n",
+ "print(f\"length of right hand 3d xyz header: {len(right_hand_3d_xyz_header)}, should be: {number_of_hand_points*3}\")\n",
+ "print(f\"length of left hand 3d xyz header: {len(left_hand_3d_xyz_header)}, should be: {number_of_hand_points*3}\")\n",
+ "print(f\"length of face 3d xyz header: {len(face_3d_xyz_header)}, should be: {number_of_face_points*3}\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 33,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "number_of_frames = mediapipe_3d_frame_trackedPoint_xyz.shape[0]\n",
+ "body_flat = body_3d_xyz.reshape(number_of_frames, number_of_body_points*3)\n",
+ "body_flat.shape\n",
+ "\n",
+ "body_dataframe = pd.DataFrame(body_flat, columns=body_3d_xyz_header)\n",
+ "body_dataframe.to_csv(str(mediapipe_3d_npy_path.parent / \"mediapipe_body_3d_xyz.csv\"), index=False)\n",
+ "\n",
+ "right_hand_flat = right_hand_3d_xyz.reshape(number_of_frames, number_of_hand_points*3)\n",
+ "right_hand_dataframe = pd.DataFrame(right_hand_flat, columns=right_hand_3d_xyz_header)\n",
+ "right_hand_dataframe.to_csv(str(mediapipe_3d_npy_path.parent / \"mediapipe_right_hand_3d_xyz.csv\"), index=False)\n",
+ "\n",
+ "left_hand_flat = left_hand_3d_xyz.reshape(number_of_frames, number_of_hand_points*3)\n",
+ "left_hand_dataframe = pd.DataFrame(left_hand_flat, columns=left_hand_3d_xyz_header)\n",
+ "left_hand_dataframe.to_csv(str(mediapipe_3d_npy_path.parent / \"mediapipe_left_hand_3d_xyz.csv\"), index=False)\n",
+ "\n",
+ "face_flat = face_3d_xyz.reshape(number_of_frames, number_of_face_points*3)\n",
+ "face_dataframe = pd.DataFrame(face_flat, columns=face_3d_xyz_header)\n",
+ "face_dataframe.to_csv(str(mediapipe_3d_npy_path.parent / \"mediapipe_face_3d_xyz.csv\"), index=False)\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3.9.12 ('fmc-endurance')",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.9.12"
+ },
+ "vscode": {
+ "interpreter": {
+ "hash": "faaa4718f81dea544b1eec21b9b5977abdad8a3ae32c87c23f8249d29cfa9e11"
+ }
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
\ No newline at end of file