| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681 |
- {
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [],
- "source": [
- "import os, sys\n",
- "import pandas as pd\n",
- "import numpy as np\n",
- "sys.path.append('../')\n",
- "import modules.coordsi as csi\n",
- "import math\n",
- "import time"
- ]
- },
- {
- "attachments": {},
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "A brief summary of each original coordinate"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Warning: ./List_Data_Call/21002290020230321/cam1.csv is not exist.\n",
- " approx_total_frame x_min x_max y_min \n",
- "./List_Data_Call/21004038220221101 478800.0 -3.0 1900.0 -2.0 \\\n",
- "./List_Data_Call/21001264420230215 219600.0 -4.0 1901.0 -6.0 \n",
- "./List_Data_Call/21001555320230216 349200.0 -5.0 1884.0 -3.0 \n",
- "./List_Data_Call/21004030420221004 666000.0 -4.0 1902.0 -3.0 \n",
- "./List_Data_Call/21004008220221017 219600.0 -8.0 1883.0 -2.0 \n",
- "\n",
- " y_max z_min z_max \n",
- "./List_Data_Call/21004038220221101 1051.0 0.923129 4.137998 \n",
- "./List_Data_Call/21001264420230215 1055.0 0.953854 4.400389 \n",
- "./List_Data_Call/21001555320230216 1057.0 0.840809 3.938679 \n",
- "./List_Data_Call/21004030420221004 1057.0 0.933506 4.356071 \n",
- "./List_Data_Call/21004008220221017 1058.0 0.897373 4.207281 \n"
- ]
- }
- ],
- "source": [
- "# initialize root path\n",
- "root = './List_Data_Call/'\n",
- "\n",
- "summary_1 = csi.summaryOriginCoord(root, camid=1)\n",
- "print(summary_1.head())"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "./List_Data_Call/21004038220221101 64.0459258556366\n",
- "./List_Data_Call/21001264420230215 34.23401594161987\n",
- "./List_Data_Call/21001555320230216 55.52943301200867\n",
- "./List_Data_Call/21004030420221004 106.67347645759583\n",
- "./List_Data_Call/21004008220221017 31.72646999359131\n",
- "./List_Data_Call/21004056620230120 19.501684188842773\n",
- "./List_Data_Call/21001057620230126 53.51554536819458\n",
- "./List_Data_Call/21003885420220721 76.24831080436707\n",
- "./List_Data_Call/21004107920230313 97.09525084495544\n",
- "./List_Data_Call/21003975920220723 36.387489318847656\n",
- "./List_Data_Call/21004102020230228 31.510535717010498\n",
- "./List_Data_Call/21004036420221013 63.18059492111206\n",
- "./List_Data_Call/21003962420220712 36.284823179244995\n",
- "./List_Data_Call/21004048220221029 50.87060260772705\n",
- "./List_Data_Call/21003992420230119 49.36880159378052\n",
- "./List_Data_Call/21001418920220921 35.04419279098511\n",
- "./List_Data_Call/21004108620230225 94.45536732673645\n",
- "./List_Data_Call/21004095420230303 7.877222776412964\n",
- "./List_Data_Call/21003655120230207 22.74891757965088\n",
- "./List_Data_Call/21003817020230107 24.885369300842285\n",
- "./List_Data_Call/21003981020220923 36.27069091796875\n",
- "./List_Data_Call/21004033920221007 86.56228399276733\n",
- "./List_Data_Call/21004074720230104 37.52795934677124\n",
- "./List_Data_Call/21004037520230324 30.00572395324707\n",
- "./List_Data_Call/21004040420221103 90.27121639251709\n",
- "./List_Data_Call/21004026620221007 69.01991891860962\n",
- "./List_Data_Call/21001870620230315 39.85080003738403\n",
- "./List_Data_Call/21004068020230102 7.841302871704102\n",
- "./List_Data_Call/21004094420230206 100.37451100349426\n",
- "./List_Data_Call/21004097420230304 84.17479515075684\n",
- "./List_Data_Call/21004047820221028 89.44327425956726\n",
- "./List_Data_Call/21004051720230228 9.743078708648682\n",
- "./List_Data_Call/21004076520230204 76.26534867286682\n",
- "./List_Data_Call/21002591020230218 88.18855333328247\n",
- "./List_Data_Call/21004105820230311 59.186476945877075\n",
- "./List_Data_Call/21004037520230317 54.6233925819397\n",
- "./List_Data_Call/21003993520220917 95.81168413162231\n",
- "./List_Data_Call/21003967920220714 36.98200988769531\n",
- "./List_Data_Call/21004043620221025 25.73115038871765\n",
- "./List_Data_Call/21004097520230208 93.56520891189575\n",
- "./List_Data_Call/21004092020230127 89.9213137626648\n",
- "./List_Data_Call/21004026220220928 81.38130640983582\n"
- ]
- },
- {
- "ename": "ValueError",
- "evalue": "Found array with 0 sample(s) (shape=(0,)) while a minimum of 1 is required.",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
- "Cell \u001b[0;32mIn[3], line 6\u001b[0m\n\u001b[1;32m 4\u001b[0m start_time \u001b[39m=\u001b[39m time\u001b[39m.\u001b[39mtime()\n\u001b[1;32m 5\u001b[0m df \u001b[39m=\u001b[39m csi\u001b[39m.\u001b[39mreadCam(os\u001b[39m.\u001b[39mpath\u001b[39m.\u001b[39mjoin(index,\u001b[39m'\u001b[39m\u001b[39mcam1.csv\u001b[39m\u001b[39m'\u001b[39m))\n\u001b[0;32m----> 6\u001b[0m df \u001b[39m=\u001b[39m csi\u001b[39m.\u001b[39;49mconvertToSI(df, \u001b[39m3.5\u001b[39;49m, \u001b[39m1.5\u001b[39;49m, \u001b[39m3.4\u001b[39;49m)\n\u001b[1;32m 7\u001b[0m df \u001b[39m=\u001b[39m csi\u001b[39m.\u001b[39mgetVelocity(df)\n\u001b[1;32m 8\u001b[0m df \u001b[39m=\u001b[39m csi\u001b[39m.\u001b[39mgetAcceleration(df)\n",
- "File \u001b[0;32m~/workspace/equation20/coordsi.py:62\u001b[0m, in \u001b[0;36mconvertToSI\u001b[0;34m(origin, w, l, h)\u001b[0m\n\u001b[1;32m 60\u001b[0m df \u001b[39m=\u001b[39m origin\u001b[39m.\u001b[39mcopy()\n\u001b[1;32m 61\u001b[0m \u001b[39m#normailze dataframe[0] from -1 to 1\u001b[39;00m\n\u001b[0;32m---> 62\u001b[0m df[\u001b[39m'\u001b[39m\u001b[39mx\u001b[39m\u001b[39m'\u001b[39m] \u001b[39m=\u001b[39m preprocessing\u001b[39m.\u001b[39;49mminmax_scale(df[\u001b[39m'\u001b[39;49m\u001b[39mx\u001b[39;49m\u001b[39m'\u001b[39;49m], feature_range\u001b[39m=\u001b[39;49m(\u001b[39m-\u001b[39;49m(w\u001b[39m/\u001b[39;49m\u001b[39m2\u001b[39;49m), (w\u001b[39m/\u001b[39;49m\u001b[39m2\u001b[39;49m)), axis\u001b[39m=\u001b[39;49m\u001b[39m0\u001b[39;49m, copy\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m)\n\u001b[1;32m 63\u001b[0m \u001b[39m#normailze dataframe[1] from -0.75 to 0.75\u001b[39;00m\n\u001b[1;32m 64\u001b[0m df[\u001b[39m'\u001b[39m\u001b[39my\u001b[39m\u001b[39m'\u001b[39m] \u001b[39m=\u001b[39m preprocessing\u001b[39m.\u001b[39mminmax_scale(df[\u001b[39m'\u001b[39m\u001b[39my\u001b[39m\u001b[39m'\u001b[39m], feature_range\u001b[39m=\u001b[39m(\u001b[39m-\u001b[39m(l\u001b[39m/\u001b[39m\u001b[39m2\u001b[39m), (l\u001b[39m/\u001b[39m\u001b[39m2\u001b[39m)), axis\u001b[39m=\u001b[39m\u001b[39m0\u001b[39m, copy\u001b[39m=\u001b[39m\u001b[39mTrue\u001b[39;00m)\n",
- "File \u001b[0;32m~/.local/lib/python3.8/site-packages/sklearn/preprocessing/_data.py:624\u001b[0m, in \u001b[0;36mminmax_scale\u001b[0;34m(X, feature_range, axis, copy)\u001b[0m\n\u001b[1;32m 550\u001b[0m \u001b[39m\u001b[39m\u001b[39m\"\"\"Transform features by scaling each feature to a given range.\u001b[39;00m\n\u001b[1;32m 551\u001b[0m \n\u001b[1;32m 552\u001b[0m \u001b[39mThis estimator scales and translates each feature individually such\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 620\u001b[0m \u001b[39m<sphx_glr_auto_examples_preprocessing_plot_all_scaling.py>`.\u001b[39;00m\n\u001b[1;32m 621\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m 622\u001b[0m \u001b[39m# Unlike the scaler object, this function allows 1d input.\u001b[39;00m\n\u001b[1;32m 623\u001b[0m \u001b[39m# If copy is required, it will be done inside the scaler object.\u001b[39;00m\n\u001b[0;32m--> 624\u001b[0m X \u001b[39m=\u001b[39m check_array(\n\u001b[1;32m 625\u001b[0m X, copy\u001b[39m=\u001b[39;49m\u001b[39mFalse\u001b[39;49;00m, ensure_2d\u001b[39m=\u001b[39;49m\u001b[39mFalse\u001b[39;49;00m, dtype\u001b[39m=\u001b[39;49mFLOAT_DTYPES, force_all_finite\u001b[39m=\u001b[39;49m\u001b[39m\"\u001b[39;49m\u001b[39mallow-nan\u001b[39;49m\u001b[39m\"\u001b[39;49m\n\u001b[1;32m 626\u001b[0m )\n\u001b[1;32m 627\u001b[0m original_ndim \u001b[39m=\u001b[39m X\u001b[39m.\u001b[39mndim\n\u001b[1;32m 629\u001b[0m \u001b[39mif\u001b[39;00m original_ndim \u001b[39m==\u001b[39m \u001b[39m1\u001b[39m:\n",
- "File \u001b[0;32m~/.local/lib/python3.8/site-packages/sklearn/utils/validation.py:931\u001b[0m, in \u001b[0;36mcheck_array\u001b[0;34m(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator, input_name)\u001b[0m\n\u001b[1;32m 929\u001b[0m n_samples \u001b[39m=\u001b[39m _num_samples(array)\n\u001b[1;32m 930\u001b[0m \u001b[39mif\u001b[39;00m n_samples \u001b[39m<\u001b[39m ensure_min_samples:\n\u001b[0;32m--> 931\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mValueError\u001b[39;00m(\n\u001b[1;32m 932\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mFound array with \u001b[39m\u001b[39m%d\u001b[39;00m\u001b[39m sample(s) (shape=\u001b[39m\u001b[39m%s\u001b[39;00m\u001b[39m) while a\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 933\u001b[0m \u001b[39m\"\u001b[39m\u001b[39m minimum of \u001b[39m\u001b[39m%d\u001b[39;00m\u001b[39m is required\u001b[39m\u001b[39m%s\u001b[39;00m\u001b[39m.\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 934\u001b[0m \u001b[39m%\u001b[39m (n_samples, array\u001b[39m.\u001b[39mshape, ensure_min_samples, context)\n\u001b[1;32m 935\u001b[0m )\n\u001b[1;32m 937\u001b[0m \u001b[39mif\u001b[39;00m ensure_min_features \u001b[39m>\u001b[39m \u001b[39m0\u001b[39m \u001b[39mand\u001b[39;00m array\u001b[39m.\u001b[39mndim \u001b[39m==\u001b[39m \u001b[39m2\u001b[39m:\n\u001b[1;32m 938\u001b[0m n_features \u001b[39m=\u001b[39m array\u001b[39m.\u001b[39mshape[\u001b[39m1\u001b[39m]\n",
- "\u001b[0;31mValueError\u001b[0m: Found array with 0 sample(s) (shape=(0,)) while a minimum of 1 is required."
- ]
- }
- ],
- "source": [
- "#make a loop for each index\n",
- "for index, row in summary_1.iterrows():\n",
- " timestamp = []\n",
- " start_time = time.time()\n",
- " df = csi.readCam(os.path.join(index,'cam1.csv'))\n",
- " df = csi.convertToSI(df, 3.5, 1.5, 3.4)\n",
- " df = csi.getVelocity(df)\n",
- " df = csi.getAcceleration(df)\n",
- " df = csi.getFullTrace(df,row['approx_total_frame'] )\n",
- " df = csi.addValidDetection(df, 25.0)\n",
- " df.to_csv(os.path.join('./handletrace/', index[17:]+'.csv'), index=False)\n",
- " #save spend time and index of summary_1 in timestamp list \n",
- " timestamp.append([index, time.time() - start_time])\n",
- "#save timestamp list to csv file\n",
- "pd.DataFrame(timestamp, columns=['index', 'time']).to_csv('./handletrace/timestamp.csv', index=False)\n",
- "\n"
- ]
- },
- {
- "attachments": {},
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "import a origin coord and convert"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {},
- "outputs": [],
- "source": [
- "arr_1 = csi.readCam(os.path.join(summary_1.index[0],'cam1.csv'))\n",
- "si_1 = csi.convertToSI(arr_1, 3.5, 1.5, 3.4)\n",
- "#cartesian coordinate system\n",
- "#구면 좌표계로 변경도 해보자...나중에...\n",
- "#meter/(1/30)s\n",
- "si_1['positionvectorvalue'] = (si_1['x']**2 + si_1['y']**2 + si_1['z']**2)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {},
- "outputs": [],
- "source": [
- "cal_buffer_1, cal_buffer_2 = si_1['positionvectorvalue'].copy(), si_1['positionvectorvalue'].copy()\n",
- "#print(cal_buffer_1,'\\n',cal_buffer_2)\n",
- "cal_buffer_1, cal_buffer_2= cal_buffer_1.to_frame(), cal_buffer_2.to_frame()\n",
- "cal_buffer_1 = list(cal_buffer_1.loc[:, 'positionvectorvalue'])\n",
- "cal_buffer_2 = list(cal_buffer_2.loc[:, 'positionvectorvalue'])\n",
- "cal_buffer_3 = [0.0]\n",
- "for v in range(0, len(cal_buffer_2)-1):\n",
- " cal_buffer_3.append(cal_buffer_2[v])\n",
- "buffer_a = np.array(cal_buffer_1)\n",
- "buffer_b = np.array(cal_buffer_3)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {},
- "outputs": [],
- "source": [
- "velocity = (buffer_a - buffer_b)\n",
- "for x in range(0, len(velocity)):\n",
- " velocity[x] = math.sqrt(abs(velocity[x]))\n",
- "velocity[0]=0.0"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {},
- "outputs": [],
- "source": [
- "#merge each list as Series\n",
- "si_1['velocity'] = velocity\n",
- "#print(si_1)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 7,
- "metadata": {},
- "outputs": [],
- "source": [
- "cal_buffer_4, cal_buffer_5 = si_1['velocity'].copy(), si_1['velocity'].copy()\n",
- "#print(cal_buffer_1,'\\n',cal_buffer_2)\n",
- "cal_buffer_4, cal_buffer_5= cal_buffer_4.to_frame(), cal_buffer_5.to_frame()\n",
- "cal_buffer_4 = list(cal_buffer_4.loc[:, 'velocity'])\n",
- "cal_buffer_5 = list(cal_buffer_5.loc[:, 'velocity'])\n",
- "cal_buffer_6 = [0.0]\n",
- "for v in range(0, len(cal_buffer_5)-1):\n",
- " cal_buffer_6.append(cal_buffer_5[v])\n",
- "buffer_c = np.array(cal_buffer_4)\n",
- "buffer_d = np.array(cal_buffer_6)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 8,
- "metadata": {},
- "outputs": [],
- "source": [
- "acceleration = buffer_c - buffer_d\n",
- "acceleration[1] = 0.0\n",
- "#print(acceleration)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 9,
- "metadata": {},
- "outputs": [],
- "source": [
- "si_1['acceleration'] = acceleration\n",
- "#print(si_1)"
- ]
- },
- {
- "attachments": {},
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Calculate Velocity of all detected objects"
- ]
- },
- {
- "attachments": {},
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "\n",
- "TODO: approx_total_frame 개수 만큼의 빈 컬럼 생성 (나중에 전체 데이터프레임은 20등분으로 잘릴 예정) -> done\n",
- "실제 값이 존재하는 프레임을 찾고, 그 프레임을 인덱스에 맞추어 x,y,z 집어넣기\n",
- "존재한다면 (x^2 + y^2 + z^2)^(1/3) 을 계산하여 새 컬럼에 저장\n",
- "비 등속 보간 작업을 해야 하는데, 어떤 방식으로 할지 결정하기(piecewise_polynomial?)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 11,
- "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>x</th>\n",
- " <th>y</th>\n",
- " <th>z</th>\n",
- " <th>frame</th>\n",
- " <th>positionvectorvalue</th>\n",
- " <th>velocity</th>\n",
- " <th>acceleration</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>count</th>\n",
- " <td>62495.000000</td>\n",
- " <td>62495.000000</td>\n",
- " <td>62495.000000</td>\n",
- " <td>62495.000000</td>\n",
- " <td>62495.000000</td>\n",
- " <td>62495.000000</td>\n",
- " <td>62495.000000</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>mean</th>\n",
- " <td>-0.202211</td>\n",
- " <td>-0.207365</td>\n",
- " <td>1.601385</td>\n",
- " <td>42805.432355</td>\n",
- " <td>2.733538</td>\n",
- " <td>0.138262</td>\n",
- " <td>0.000002</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>std</th>\n",
- " <td>0.162759</td>\n",
- " <td>0.238811</td>\n",
- " <td>0.041177</td>\n",
- " <td>27211.098449</td>\n",
- " <td>0.162993</td>\n",
- " <td>0.120752</td>\n",
- " <td>0.124054</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>min</th>\n",
- " <td>-0.750000</td>\n",
- " <td>-1.750000</td>\n",
- " <td>0.930000</td>\n",
- " <td>1.000000</td>\n",
- " <td>1.109630</td>\n",
- " <td>0.000000</td>\n",
- " <td>-1.650274</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>25%</th>\n",
- " <td>-0.328348</td>\n",
- " <td>-0.377956</td>\n",
- " <td>1.574043</td>\n",
- " <td>19851.500000</td>\n",
- " <td>2.637680</td>\n",
- " <td>0.067702</td>\n",
- " <td>-0.045567</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>50%</th>\n",
- " <td>-0.183048</td>\n",
- " <td>-0.240016</td>\n",
- " <td>1.598190</td>\n",
- " <td>38725.000000</td>\n",
- " <td>2.706999</td>\n",
- " <td>0.111651</td>\n",
- " <td>0.000205</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>75%</th>\n",
- " <td>-0.096154</td>\n",
- " <td>-0.032186</td>\n",
- " <td>1.625495</td>\n",
- " <td>69024.500000</td>\n",
- " <td>2.793686</td>\n",
- " <td>0.168573</td>\n",
- " <td>0.045744</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>max</th>\n",
- " <td>0.750000</td>\n",
- " <td>1.750000</td>\n",
- " <td>1.800000</td>\n",
- " <td>233066.000000</td>\n",
- " <td>6.039652</td>\n",
- " <td>1.941675</td>\n",
- " <td>1.692079</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "</div>"
- ],
- "text/plain": [
- " x y z frame \n",
- "count 62495.000000 62495.000000 62495.000000 62495.000000 \\\n",
- "mean -0.202211 -0.207365 1.601385 42805.432355 \n",
- "std 0.162759 0.238811 0.041177 27211.098449 \n",
- "min -0.750000 -1.750000 0.930000 1.000000 \n",
- "25% -0.328348 -0.377956 1.574043 19851.500000 \n",
- "50% -0.183048 -0.240016 1.598190 38725.000000 \n",
- "75% -0.096154 -0.032186 1.625495 69024.500000 \n",
- "max 0.750000 1.750000 1.800000 233066.000000 \n",
- "\n",
- " positionvectorvalue velocity acceleration \n",
- "count 62495.000000 62495.000000 62495.000000 \n",
- "mean 2.733538 0.138262 0.000002 \n",
- "std 0.162993 0.120752 0.124054 \n",
- "min 1.109630 0.000000 -1.650274 \n",
- "25% 2.637680 0.067702 -0.045567 \n",
- "50% 2.706999 0.111651 0.000205 \n",
- "75% 2.793686 0.168573 0.045744 \n",
- "max 6.039652 1.941675 1.692079 "
- ]
- },
- "execution_count": 11,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "si_1.describe()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 12,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- " x y z frame positionvectorvalue velocity acceleration \n",
- "478795 0.0 0.0 0.0 0.0 0.0 0.0 0.0 \\\n",
- "478796 0.0 0.0 0.0 0.0 0.0 0.0 0.0 \n",
- "478797 0.0 0.0 0.0 0.0 0.0 0.0 0.0 \n",
- "478798 0.0 0.0 0.0 0.0 0.0 0.0 0.0 \n",
- "478799 0.0 0.0 0.0 0.0 0.0 0.0 0.0 \n",
- "\n",
- " isValid \n",
- "478795 0.0 \n",
- "478796 0.0 \n",
- "478797 0.0 \n",
- "478798 0.0 \n",
- "478799 0.0 \n"
- ]
- }
- ],
- "source": [
- "# create dataframe with 6 columns and create 0 value rows as many as approx_total_frame value in summary_1\n",
- "j = 0\n",
- "handletrace = pd.DataFrame(columns=['x', 'y', 'z', 'frame', 'positionvectorvalue', 'velocity', 'acceleration', 'isValid'])\n",
- "handletrace = pd.concat([handletrace, pd.DataFrame(np.zeros((int(summary_1['approx_total_frame'][j]),8)), columns=['x', 'y', 'z', 'frame', 'positionvectorvalue','velocity', 'acceleration', 'isValid'])], axis=0)\n",
- "print(handletrace.tail())"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#print(int(si_1['frame'][2]))\n",
- "#print(si_1.loc[2])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 13,
- "metadata": {},
- "outputs": [],
- "source": [
- "# frame의 값에 해당하는 것으로 변경\n",
- "for x in range(0, len(si_1)):\n",
- " handletrace.loc[int(si_1['frame'][x])] = si_1.loc[x]\n",
- "handletrace['isValid'] = handletrace['isValid'].fillna(0)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 14,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- " x y z frame positionvectorvalue velocity \n",
- "0 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 \\\n",
- "1 -0.400997 -0.319101 1.632182 1.0 2.926644 0.000000 \n",
- "2 -0.410969 -0.333815 1.629004 2.0 2.933981 0.085661 \n",
- "3 -0.412393 -0.352207 1.634730 3.0 2.966459 0.180214 \n",
- "4 -0.413818 -0.357725 1.638935 4.0 2.985322 0.137342 \n",
- "... ... ... ... ... ... ... \n",
- "478795 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 \n",
- "478796 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 \n",
- "478797 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 \n",
- "478798 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 \n",
- "478799 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 \n",
- "\n",
- " acceleration isValid \n",
- "0 0.000000 0.0 \n",
- "1 0.000000 0.0 \n",
- "2 0.000000 0.0 \n",
- "3 0.094553 0.0 \n",
- "4 -0.042873 0.0 \n",
- "... ... ... \n",
- "478795 0.000000 0.0 \n",
- "478796 0.000000 0.0 \n",
- "478797 0.000000 0.0 \n",
- "478798 0.000000 0.0 \n",
- "478799 0.000000 0.0 \n",
- "\n",
- "[478800 rows x 8 columns]\n"
- ]
- }
- ],
- "source": [
- "print(handletrace)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "'''import plotly.graph_objects as go\n",
- "\n",
- "#Create Figure\n",
- "fig = go.Figure()\n",
- "fig.add_trace(go.Scatter( x=list(handletrace.index), y=list(handletrace['velocity'] * 30)))\n",
- "\n",
- "#Set Title\n",
- "fig.update_layout(title_text='Velocity per second by frame')\n",
- "\n",
- "#Add range slider\n",
- "fig.update_layout(\n",
- " xaxis=dict(\n",
- " rangeslider=dict(\n",
- " visible=True\n",
- " )\n",
- " )\n",
- ")'''"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "'''import plotly.graph_objects as go\n",
- "\n",
- "#Create Figure\n",
- "fig = go.Figure()\n",
- "fig.add_trace(go.Scatter( x=list(handletrace.index), y=list(handletrace['acceleration']*900)))\n",
- "\n",
- "#Set Title\n",
- "fig.update_layout(title_text='acceleration per second^2 by frame')\n",
- "\n",
- "#Add range slider\n",
- "fig.update_layout(\n",
- " xaxis=dict(\n",
- " rangeslider=dict(\n",
- " visible=True\n",
- " )\n",
- " )\n",
- ")'''"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 15,
- "metadata": {},
- "outputs": [],
- "source": [
- "#comapre the value of handletrace['acceleration'] and if it is between -25 and 25, then set handletrace['isValid'] to 1\n",
- "for x in range(0, len(handletrace)):\n",
- " if (-25/900) < handletrace['acceleration'][x] < (25/900):\n",
- " handletrace['isValid'][x] = 1\n",
- " else:\n",
- " handletrace['isValid'][x] = 0"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 16,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "[1. 0.]\n",
- "isValid\n",
- "1.0 437730\n",
- "0.0 41070\n",
- "Name: count, dtype: int64\n"
- ]
- }
- ],
- "source": [
- "print(handletrace['isValid'].unique())\n",
- "print(handletrace['isValid'].value_counts())"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 17,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- " x y z frame positionvectorvalue velocity \n",
- "0 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 \\\n",
- "1 -0.400997 -0.319101 1.632182 1.0 2.926644 0.000000 \n",
- "2 -0.410969 -0.333815 1.629004 2.0 2.933981 0.085661 \n",
- "3 -0.412393 -0.352207 1.634730 3.0 2.966459 0.180214 \n",
- "4 -0.413818 -0.357725 1.638935 4.0 2.985322 0.137342 \n",
- "... ... ... ... ... ... ... \n",
- "478795 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 \n",
- "478796 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 \n",
- "478797 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 \n",
- "478798 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 \n",
- "478799 0.000000 0.000000 0.000000 0.0 0.000000 0.000000 \n",
- "\n",
- " acceleration isValid \n",
- "0 0.000000 1.0 \n",
- "1 0.000000 1.0 \n",
- "2 0.000000 1.0 \n",
- "3 0.094553 0.0 \n",
- "4 -0.042873 0.0 \n",
- "... ... ... \n",
- "478795 0.000000 1.0 \n",
- "478796 0.000000 1.0 \n",
- "478797 0.000000 1.0 \n",
- "478798 0.000000 1.0 \n",
- "478799 0.000000 1.0 \n",
- "\n",
- "[478800 rows x 8 columns]\n"
- ]
- }
- ],
- "source": [
- "print(handletrace)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "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.8.0"
- },
- "vscode": {
- "interpreter": {
- "hash": "df0893f56f349688326838aaeea0de204df53a132722cbd565e54b24a8fec5f6"
- }
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
|