Skip to content

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

TypeScript

for digging into the `timestamps.csv` that comes out of the `multi_camera_handler.py`

Jon0e67424fd5d1
diff --git a/jon_scratch/examine_timestamps.ipynb b/jon_scratch/examine_timestamps.ipynb
new file mode 100644
index 00000000..82090aaf
--- /dev/null
+++ b/jon_scratch/examine_timestamps.ipynb
@@ -0,0 +1,318 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import pandas as pd\n",
+ "import numpy as np\n",
+ "from pathlib import Path\n",
+ "from matplotlib import pyplot as plt\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ " Unnamed: 0 Camera0 Camera1 Camera2\n",
+ "0 0 1.643064e+09 1.643064e+09 1.643064e+09\n",
+ "1 1 1.643064e+09 1.643064e+09 1.643064e+09\n",
+ "2 2 1.643064e+09 1.643064e+09 1.643064e+09\n",
+ "3 3 1.643064e+09 1.643064e+09 1.643064e+09\n",
+ "4 4 1.643064e+09 1.643064e+09 1.643064e+09\n",
+ ".. ... ... ... ...\n",
+ "140 140 1.643064e+09 1.643064e+09 1.643064e+09\n",
+ "141 141 1.643064e+09 1.643064e+09 1.643064e+09\n",
+ "142 142 1.643064e+09 1.643064e+09 1.643064e+09\n",
+ "143 143 1.643064e+09 1.643064e+09 1.643064e+09\n",
+ "144 144 1.643064e+09 1.643064e+09 1.643064e+09\n",
+ "\n",
+ "[145 rows x 4 columns]\n"
+ ]
+ }
+ ],
+ "source": [
+ "\n",
+ "path_to_timestamps = Path('~/timestamps.csv')\n",
+ "timestamps_df = pd.read_csv(path_to_timestamps)\n",
+ "\n",
+ "print(timestamps_df)\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ " Unnamed: 0 Camera0 Camera1 Camera2\n",
+ "0 0.0 0.000000 0.000000 0.000000\n",
+ "1 1.0 0.001001 0.002000 0.187001\n",
+ "2 2.0 0.025000 0.031500 0.218002\n",
+ "3 3.0 0.057001 0.063001 0.250002\n",
+ "4 4.0 0.090501 0.096501 0.282006\n",
+ ".. ... ... ... ...\n",
+ "140 140.0 4.633425 4.622925 4.826427\n",
+ "141 141.0 4.666926 4.671926 4.858427\n",
+ "142 142.0 4.697927 4.703427 4.890428\n",
+ "143 143.0 4.729926 4.735926 4.922928\n",
+ "144 144.0 4.761926 4.767427 4.953428\n",
+ "\n",
+ "[145 rows x 4 columns]\n"
+ ]
+ }
+ ],
+ "source": [
+ "min_ts = timestamps_df.min()\n",
+ "timestamps_df =timestamps_df - min_ts\n",
+ "print(timestamps_df)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "\n",
+ "cam0_ts = timestamps_df['Camera0'].to_numpy()\n",
+ "cam1_ts = timestamps_df['Camera1'].to_numpy()\n",
+ "cam2_ts = timestamps_df['Camera2'].to_numpy()\n",
+ "cam0_id_ts = np.vstack([np.zeros(len(cam0_ts)), cam0_ts])\n",
+ "cam1_id_ts = np.vstack([np.zeros(len(cam1_ts))+1, cam0_ts])\n",
+ "cam2_id_ts = np.vstack([np.zeros(len(cam2_ts))+2, cam0_ts])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ " camID timestamp\n",
+ "0 0.0 0.000000\n",
+ "1 0.0 0.001001\n",
+ "2 0.0 0.025000\n",
+ "3 0.0 0.057001\n",
+ "4 0.0 0.090501\n",
+ ".. ... ...\n",
+ "430 2.0 4.633425\n",
+ "431 2.0 4.666926\n",
+ "432 2.0 4.697927\n",
+ "433 2.0 4.729926\n",
+ "434 2.0 4.761926\n",
+ "\n",
+ "[435 rows x 2 columns]\n"
+ ]
+ }
+ ],
+ "source": [
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "allTimestamps_id_ts = np.hstack([cam0_id_ts, cam1_id_ts, cam2_id_ts])\n",
+ "allTimestamps_df = pd.DataFrame(allTimestamps_id_ts.T, columns=['camID', 'timestamp'])\n",
+ "print(allTimestamps_df)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ " camID timestamp\n",
+ "0 0.0 0.000000\n",
+ "290 2.0 0.000000\n",
+ "145 1.0 0.000000\n",
+ "1 0.0 0.001001\n",
+ "291 2.0 0.001001\n",
+ ".. ... ...\n",
+ "143 0.0 4.729926\n",
+ "288 1.0 4.729926\n",
+ "289 1.0 4.761926\n",
+ "144 0.0 4.761926\n",
+ "434 2.0 4.761926\n",
+ "\n",
+ "[435 rows x 2 columns]\n"
+ ]
+ }
+ ],
+ "source": [
+ "allTimestamps_df = allTimestamps_df.sort_values(by=['timestamp'])\n",
+ "print(allTimestamps_df)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Using matplotlib backend: TkAgg\n"
+ ]
+ }
+ ],
+ "source": [
+ "%matplotlib \n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "[<matplotlib.lines.Line2D at 0x22b4d05d848>]"
+ ]
+ },
+ "execution_count": 17,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "colors = ['red', 'green', 'blue']\n",
+ "figure, ax = plt.subplots()\n",
+ "plt.plot(allTimestamps_df['timestamp'], allTimestamps_df['camID'], '-o') \n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "<div>\n",
+ "<style scoped>\n",
+ " .dataframe tbody tr th:only-of-type {\n",
+ " vertical-align: middle;\n",
+ " }\n",
+ "\n",
+ " .dataframe tbody tr th {\n",
+ " vertical-align: top;\n",
+ " }\n",
+ "\n",
+ " .dataframe thead th {\n",
+ " text-align: right;\n",
+ " }\n",
+ "</style>\n",
+ "<table border=\"1\" class=\"dataframe\">\n",
+ " <thead>\n",
+ " <tr style=\"text-align: right;\">\n",
+ " <th></th>\n",
+ " <th>camID</th>\n",
+ " <th>timestamp</th>\n",
+ " </tr>\n",
+ " </thead>\n",
+ " <tbody>\n",
+ " <tr>\n",
+ " <th>0</th>\n",
+ " <td>0.0</td>\n",
+ " <td>0.0</td>\n",
+ " </tr>\n",
+ " </tbody>\n",
+ "</table>\n",
+ "</div>"
+ ],
+ "text/plain": [
+ " camID timestamp\n",
+ "0 0.0 0.0"
+ ]
+ },
+ "execution_count": 30,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "allTimestamps_df.loc[:0]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "a = np.random.rand(4,2)\n",
+ "b = np.random.rand(4,2)\n",
+ "a[:,1] = 1\n",
+ "b[:,1] = 2\n",
+ "# print(a)\n",
+ "# print(b)\n",
+ "\n",
+ "ab_raw = np.vstack([a,b])\n",
+ "\n",
+ "# print('ab_raw')\n",
+ "# print(ab_raw)\n",
+ "\n",
+ "ab_raw_df = pd.DataFrame(data=ab_raw, columns=['num', 'id'])\n",
+ "\n",
+ "print(ab_raw_df)\n",
+ "\n",
+ "ab_sorted = ab_raw_df.sort_values(by=['num'])\n",
+ "print(ab_sorted)\n",
+ "# ab = np.sort(ab_raw)\n",
+ "# print(ab)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "interpreter": {
+ "hash": "a27e02b00040eb3222236c12664def6c278394870265aa932cf722c3b1a8ef6b"
+ },
+ "kernelspec": {
+ "display_name": "Python 3.7.11 64-bit ('fmc-env': conda)",
+ "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.7.11"
+ },
+ "orig_nbformat": 4
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}