{ "cells": [ { "cell_type": "code", "execution_count": 12, "id": "805fb727", "metadata": {}, "outputs": [], "source": [ "import json\n", "import pandas as pd\n", "import numpy as np\n", "import cv2 as cv\n", "from scipy.spatial.transform import Rotation as R" ] }, { "cell_type": "code", "execution_count": 13, "id": "456ca3a7", "metadata": {}, "outputs": [], "source": [ "path = \"/home/ivan/ivan/git/work_drivecast2/SLAM/ORB_SLAM3-1.0-release/Examples/Stereo/CameraTrajectory.txt\"\n", "traj = pd.read_csv(path, sep=\" \")" ] }, { "cell_type": "code", "execution_count": 14, "id": "95b5c6ad", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
1.000000000-0.000088794-0.0001747360.0037048300.0000887591.000000000.1-0.0002034400.0030009860.0001747540.0002034240.999999940-0.002705306
00.9999980.0009210.001840-0.005423-0.0009180.999999-0.001342-0.013499-0.0018410.0013400.9999971.208114
10.9999950.0012850.002990-0.005176-0.0012820.999999-0.000825-0.035608-0.0029910.0008210.9999952.407335
20.9999910.0007460.004218-0.006803-0.0007441.000000-0.000477-0.056003-0.0042190.0004740.9999913.605217
30.9999870.0006190.005148-0.005932-0.0006171.000000-0.000506-0.076681-0.0051480.0005030.9999874.807625
40.9999820.0002330.005998-0.002676-0.0002311.000000-0.000369-0.099023-0.0059980.0003670.9999826.011686
.......................................
10950.9996740.0184860.0176360.309588-0.0184510.999827-0.002142-4.813883-0.0176730.0018160.999842298.364136
10960.9997230.0172070.0160260.323237-0.0171970.999852-0.000755-4.829275-0.0160370.0004790.999871299.153198
10970.9997470.0171540.0145460.331380-0.0171580.9998530.000127-4.843719-0.014542-0.0003760.999894299.964447
10980.9998050.0151070.0127140.345279-0.0151220.9998850.001079-4.859191-0.012696-0.0012710.999919300.759399
10990.9998480.0135950.0108930.348502-0.0136170.9999050.001920-4.872813-0.010865-0.0020680.999939301.564575
\n", "

1100 rows × 12 columns

\n", "
" ], "text/plain": [ " 1.000000000 -0.000088794 -0.000174736 0.003704830 0.000088759 \\\n", "0 0.999998 0.000921 0.001840 -0.005423 -0.000918 \n", "1 0.999995 0.001285 0.002990 -0.005176 -0.001282 \n", "2 0.999991 0.000746 0.004218 -0.006803 -0.000744 \n", "3 0.999987 0.000619 0.005148 -0.005932 -0.000617 \n", "4 0.999982 0.000233 0.005998 -0.002676 -0.000231 \n", "... ... ... ... ... ... \n", "1095 0.999674 0.018486 0.017636 0.309588 -0.018451 \n", "1096 0.999723 0.017207 0.016026 0.323237 -0.017197 \n", "1097 0.999747 0.017154 0.014546 0.331380 -0.017158 \n", "1098 0.999805 0.015107 0.012714 0.345279 -0.015122 \n", "1099 0.999848 0.013595 0.010893 0.348502 -0.013617 \n", "\n", " 1.000000000.1 -0.000203440 0.003000986 0.000174754 0.000203424 \\\n", "0 0.999999 -0.001342 -0.013499 -0.001841 0.001340 \n", "1 0.999999 -0.000825 -0.035608 -0.002991 0.000821 \n", "2 1.000000 -0.000477 -0.056003 -0.004219 0.000474 \n", "3 1.000000 -0.000506 -0.076681 -0.005148 0.000503 \n", "4 1.000000 -0.000369 -0.099023 -0.005998 0.000367 \n", "... ... ... ... ... ... \n", "1095 0.999827 -0.002142 -4.813883 -0.017673 0.001816 \n", "1096 0.999852 -0.000755 -4.829275 -0.016037 0.000479 \n", "1097 0.999853 0.000127 -4.843719 -0.014542 -0.000376 \n", "1098 0.999885 0.001079 -4.859191 -0.012696 -0.001271 \n", "1099 0.999905 0.001920 -4.872813 -0.010865 -0.002068 \n", "\n", " 0.999999940 -0.002705306 \n", "0 0.999997 1.208114 \n", "1 0.999995 2.407335 \n", "2 0.999991 3.605217 \n", "3 0.999987 4.807625 \n", "4 0.999982 6.011686 \n", "... ... ... \n", "1095 0.999842 298.364136 \n", "1096 0.999871 299.153198 \n", "1097 0.999894 299.964447 \n", "1098 0.999919 300.759399 \n", "1099 0.999939 301.564575 \n", "\n", "[1100 rows x 12 columns]" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "traj" ] }, { "cell_type": "code", "execution_count": 15, "id": "77d852aa", "metadata": {}, "outputs": [], "source": [ "with open(\"/home/ivan/Downloads/Telegram Desktop/test_data.json\") as f:\n", " traj_example = json.load(f)" ] }, { "cell_type": "code", "execution_count": 16, "id": "2eb4a8c7", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'frame': 2,\n", " 'poses': [{'camera_id': 0,\n", " 'Euler angles': [179.0592276314431, 178.71021095455262, 12.371121058785771],\n", " 'xyz coords': [1598.4821251839471, 294.28354659765137, -65.4766852385318]},\n", " {'object_id': 2,\n", " 'Euler angles': [179.0592276314431, 178.71021095455262, 12.371121058785771],\n", " 'xyz coords': [1598.4821251839471, 294.28354659765137, -65.4766852385318]}]}" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "traj_example[\"data\"][1]" ] }, { "cell_type": "code", "execution_count": 24, "id": "b30e79c9", "metadata": {}, "outputs": [], "source": [ "json_traj_example = {\"data\": [\n", " {\"frame\":0, \n", " \"poses\":{\n", " \"euler_angles\":[0.0,0.0,0.0],\n", " \"xyz_coords\":[0.0,0.0,0.0]\n", " }\n", " }\n", " ]\n", " }\n", "\n", "json_traj = {\"data\": [\n", " ]\n", " }\n", "\n", "# Fill the first line\n", "Twc = traj.loc[0]\n", "# ---- Using SciPy ----\n", "Rot = R.from_matrix([[Twc[0], Twc[1], Twc[2]], \n", " [Twc[4], Twc[5], Twc[6]], \n", " [Twc[8], Twc[9], Twc[10]]])\n", "# \"zxy\" axes in which the data was written.\n", "euler = Rot.as_euler('zxy', degrees=True)\n", "\n", "\n", "# ---- Using OpenCV ----\n", "# mat = np.array([[Twc[0], Twc[1], Twc[2]], \n", "# [Twc[4], Twc[5], Twc[6]], \n", "# [Twc[8], Twc[9], Twc[10]]])\n", "# euler, _ = cv.Rodrigues(mat)\n", "# print(euler)\n", "\n", "\n", "# Coordinate system in ORB-SLAM3: ZXY. Coordinate system in UE4: XYZ \n", "entry = {\"frame\":0, \"poses\":[{\"camera_id\":0, \"euler_angles\":[-euler[0], -euler[1], -euler[2]], \n", " \"xyz_coords\":[-Twc[7], Twc[11], Twc[3]]},\n", " {\"cube_id\":0, \"euler_angles\":[0.0, 0.0, 0.0], \n", " \"xyz_coords\":[-33.81, 5.15, 0.82]},\n", " {\"cube_id\":1, \"euler_angles\":[0.0, 0.0, 0.0], \n", " \"xyz_coords\":[-11.5, 0.7, 0.56]},\n", " {\"cube_id\":2, \"euler_angles\":[0.0, 0.0, 0.0], \n", " \"xyz_coords\":[-95.0, 5.15, 0.8]},\n", " {\"cube_id\":3, \"euler_angles\":[0.0, 0.0, 0.0], \n", " \"xyz_coords\":[-130.3, 4.6, 2.1]},\n", " {\"cube_id\":4, \"euler_angles\":[0.0, 0.0, 0.0], \n", " \"xyz_coords\":[-346.5, 4.1, 5.9]},\n", " {\"cube_id\":5, \"euler_angles\":[0.0, 0.0, 0.0], \n", " \"xyz_coords\":[-346.5, 25.7, 4.8]},\n", " ]\n", " }\n", "json_traj[\"data\"].append(entry)\n", "\n", "\n", "for i in range(1, len(traj.index)):\n", " Twc = traj.loc[i]\n", " Rot = R.from_matrix([[Twc[0], Twc[1], Twc[2]], \n", " [Twc[4], Twc[5], Twc[6]], \n", " [Twc[8], Twc[9], Twc[10]]])\n", " # \"zxy\" axes in which the data was written.\n", " euler = Rot.as_euler('zxy', degrees=True)\n", " entry = {\"frame\":i, \"poses\":\n", " [\n", " {\"camera_id\":0, \"euler_angles\":[-euler[0], -euler[1], -euler[2]], \n", " \"xyz_coords\":[Twc[7], Twc[11], Twc[3]]}\n", " ]\n", " }\n", " json_traj[\"data\"].append(entry)" ] }, { "cell_type": "code", "execution_count": 23, "id": "e7426f0a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[{'frame': 300,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-0.88910850407191, 2.4591441886472722, 80.37741801769594],\n", " 'xyz_coords': [-4.726807594, 301.43762207, -6.798690796]}]},\n", " {'frame': 301,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-0.9075796600165297,\n", " 2.6294084940531683,\n", " 84.06915526525081],\n", " 'xyz_coords': [-4.722153664, 301.430114746, -7.194885254]}]},\n", " {'frame': 302,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-1.0180581709390197,\n", " 2.879258284354658,\n", " 87.84689637875711],\n", " 'xyz_coords': [-4.704548836, 301.407470703, -7.62802124]}]},\n", " {'frame': 303,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-1.1072425336741412,\n", " 3.1903737615281376,\n", " 91.63852552204578],\n", " 'xyz_coords': [-4.689930916, 301.33392334, -8.040527344]}]},\n", " {'frame': 304,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-1.2483647821382053,\n", " 3.5282054825867815,\n", " 95.51383269144806],\n", " 'xyz_coords': [-4.676095963, 301.247314453, -8.476318359]}]},\n", " {'frame': 305,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-1.3944193515192362,\n", " 3.8252643707501646,\n", " 99.37892243230165],\n", " 'xyz_coords': [-4.661017418, 301.130187988, -8.901000977]}]},\n", " {'frame': 306,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-1.6252226301653023,\n", " 4.07476760408856,\n", " 103.29682799509975],\n", " 'xyz_coords': [-4.636759758, 300.98538208, -9.359649658]}]},\n", " {'frame': 307,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-1.895529216479995,\n", " 4.205610716493375,\n", " 107.17038907787398],\n", " 'xyz_coords': [-4.604392052, 300.812744141, -9.811004639]}]},\n", " {'frame': 308,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.081740704089277,\n", " 4.2886427866268315,\n", " 110.80848442698726],\n", " 'xyz_coords': [-4.596663475, 300.598937988, -10.18258667]}]},\n", " {'frame': 309,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.2697271123047793,\n", " 4.19767893799276,\n", " 114.47851277672957],\n", " 'xyz_coords': [-4.564870834, 300.362670898, -10.606628418]}]},\n", " {'frame': 310,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.459921920256457, 4.11201139650582, 118.09103233790375],\n", " 'xyz_coords': [-4.531009674, 300.093994141, -11.053161621]}]},\n", " {'frame': 311,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.5664469484769614,\n", " 4.0246856206826305,\n", " 121.48383441734357],\n", " 'xyz_coords': [-4.495966911, 299.778045654, -11.494720459]}]},\n", " {'frame': 312,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.662163556412464,\n", " 3.9504205815006115,\n", " 124.65433657883165],\n", " 'xyz_coords': [-4.457000732, 299.42364502, -11.948120117]}]},\n", " {'frame': 313,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.8007727163614704,\n", " 3.9790184157131825,\n", " 127.54058814835982],\n", " 'xyz_coords': [-4.428672791, 299.041595459, -12.384277344]}]},\n", " {'frame': 314,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.0446831729624866,\n", " 4.04910834990885,\n", " 130.28617913002645],\n", " 'xyz_coords': [-4.39626503, 298.633758545, -12.813171387]}]},\n", " {'frame': 315,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.5571823255453823,\n", " 4.174401692630353,\n", " 133.11207509545008],\n", " 'xyz_coords': [-4.364857674, 298.19430542, -13.235870361]}]},\n", " {'frame': 316,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.958714510542595,\n", " 4.2608204043251385,\n", " 136.03799679820767],\n", " 'xyz_coords': [-4.322006226, 297.704864502, -13.694854736]}]},\n", " {'frame': 317,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.152107283069568, 4.209786762697597, 138.8332625747677],\n", " 'xyz_coords': [-4.278450012, 297.174316406, -14.135406494]}]},\n", " {'frame': 318,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.145637022012476, 3.9640243262705646, 141.463296992438],\n", " 'xyz_coords': [-4.245808601, 296.623565674, -14.524627686]}]},\n", " {'frame': 319,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.178934620586371,\n", " 3.5954979144387815,\n", " 143.98816607718592],\n", " 'xyz_coords': [-4.196003437, 296.028656006, -14.907928467]}]},\n", " {'frame': 320,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.082988396347756,\n", " 3.2163162834888093,\n", " 146.4292931788194],\n", " 'xyz_coords': [-4.154863834, 295.389892578, -15.286834717]}]},\n", " {'frame': 321,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.197867807940716,\n", " 2.943720230716938,\n", " 148.90682640615248],\n", " 'xyz_coords': [-4.117145061, 294.725708008, -15.682525635]}]},\n", " {'frame': 322,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.165817576181048, 2.840054638858489, 151.2284446416958],\n", " 'xyz_coords': [-4.080936432, 294.032775879, -16.010131836]}]},\n", " {'frame': 323,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.003653813187422,\n", " 2.6912417607286887,\n", " 153.60837507266737],\n", " 'xyz_coords': [-4.045372009, 293.294311523, -16.352722168]}]},\n", " {'frame': 324,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.142059073165648,\n", " 2.5696779088620625,\n", " 156.0019020676884],\n", " 'xyz_coords': [-4.017317772, 292.514770508, -16.685302734]}]},\n", " {'frame': 325,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.3312720086385035, 2.500113447346058, 158.430924213187],\n", " 'xyz_coords': [-3.982856512, 291.697570801, -16.99710083]}]},\n", " {'frame': 326,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.5921627561071565,\n", " 2.4302019025847486,\n", " 160.79656799372037],\n", " 'xyz_coords': [-3.955025673, 290.854309082, -17.278274536]}]},\n", " {'frame': 327,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.6718436524073566,\n", " 2.482304972066489,\n", " 163.06226836120618],\n", " 'xyz_coords': [-3.925811529, 289.960693359, -17.5287323]}]},\n", " {'frame': 328,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.893195030447066, 2.47202932955818, 165.2905203892855],\n", " 'xyz_coords': [-3.891076565, 289.071228027, -17.757919312]}]},\n", " {'frame': 329,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.899220439109389,\n", " 2.3819085245092464,\n", " 167.4328248065656],\n", " 'xyz_coords': [-3.862210751, 288.122375488, -17.955215454]}]},\n", " {'frame': 330,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.9323554168624755,\n", " 2.1256229526237838,\n", " 169.43812308219373],\n", " 'xyz_coords': [-3.8359375, 287.142456055, -18.128837585]}]},\n", " {'frame': 331,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.906139330307405,\n", " 1.8628350079570737,\n", " 171.37989647657028],\n", " 'xyz_coords': [-3.802873135, 286.140960693, -18.271743774]}]},\n", " {'frame': 332,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.90091055260818,\n", " 1.7572668228176216,\n", " 173.22270855488554],\n", " 'xyz_coords': [-3.769515038, 285.115142822, -18.391159058]}]},\n", " {'frame': 333,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.862490178865668,\n", " 1.7123321737391406,\n", " 174.97049956388076],\n", " 'xyz_coords': [-3.749129295, 284.076751709, -18.477348328]}]},\n", " {'frame': 334,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.884382946722072,\n", " 1.5750109127026888,\n", " 176.64806303674848],\n", " 'xyz_coords': [-3.726772308, 282.978179932, -18.54001236]}]},\n", " {'frame': 335,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.894017070760289,\n", " 1.5015580687183505,\n", " 178.19091019343875],\n", " 'xyz_coords': [-3.704230309, 281.872070312, -18.57352066]}]},\n", " {'frame': 336,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.785947598329642,\n", " 1.5218428359047436,\n", " 179.61700423626394],\n", " 'xyz_coords': [-3.685238838, 280.723693848, -18.569515228]}]},\n", " {'frame': 337,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.713105731761439,\n", " 1.5287555979830776,\n", " -179.04413493984484],\n", " 'xyz_coords': [-3.664836884, 279.560241699, -18.544895172]}]},\n", " {'frame': 338,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.609357604909199,\n", " 1.429150821081804,\n", " -177.88796249422558],\n", " 'xyz_coords': [-3.642601252, 278.382324219, -18.495584488]}]},\n", " {'frame': 339,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.340587731968131,\n", " 1.2605188611996414,\n", " -176.94212879420098],\n", " 'xyz_coords': [-3.626634598, 277.193054199, -18.425216675]}]},\n", " {'frame': 340,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-4.07611274722068,\n", " 1.1775131727138681,\n", " -176.23346560697843],\n", " 'xyz_coords': [-3.607391119, 275.988220215, -18.336606979]}]},\n", " {'frame': 341,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.8181933655368603,\n", " 1.280232264470346,\n", " -175.78929727715953],\n", " 'xyz_coords': [-3.591504335, 274.758148193, -18.230958939]}]},\n", " {'frame': 342,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.637861037422551,\n", " 1.3394125383466993,\n", " -175.59164232328922],\n", " 'xyz_coords': [-3.576166868, 273.497497559, -18.120512009]}]},\n", " {'frame': 343,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.517070150834229,\n", " 1.2474459785427328,\n", " -175.56931051085772],\n", " 'xyz_coords': [-3.552627325, 272.215637207, -18.013782501]}]},\n", " {'frame': 344,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.3754295644208416,\n", " 1.1932480101253549,\n", " -175.69991540565778],\n", " 'xyz_coords': [-3.534384489, 270.917449951, -17.899469376]}]},\n", " {'frame': 345,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.357943375911483,\n", " 1.25317889970052,\n", " -175.84363436988286],\n", " 'xyz_coords': [-3.52042675, 269.600891113, -17.795982361]}]},\n", " {'frame': 346,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.3039572444942484,\n", " 1.3020661634627344,\n", " -175.97247078369824],\n", " 'xyz_coords': [-3.50047183, 268.287445068, -17.70300293]}]},\n", " {'frame': 347,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.2416827415474994,\n", " 1.3445069726599927,\n", " -176.19931149961315],\n", " 'xyz_coords': [-3.484779358, 266.951019287, -17.603757858]}]},\n", " {'frame': 348,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.1731115804620322,\n", " 1.4732774142100646,\n", " -176.47204934428987],\n", " 'xyz_coords': [-3.471530914, 265.610900879, -17.518001556]}]},\n", " {'frame': 349,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.1443292126907485,\n", " 1.5913377349576618,\n", " -176.7997764847795],\n", " 'xyz_coords': [-3.450266361, 264.273101807, -17.432682037]}]},\n", " {'frame': 350,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.1053391308872436,\n", " 1.7078494069840966,\n", " -177.1074718107529],\n", " 'xyz_coords': [-3.435852051, 262.926574707, -17.355903625]}]},\n", " {'frame': 351,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.086666697058974,\n", " 1.7122968395794698,\n", " -177.39038111487784],\n", " 'xyz_coords': [-3.4202981, 261.582305908, -17.286437988]}]},\n", " {'frame': 352,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.982979629286457,\n", " 1.6718222894987702,\n", " -177.69601929411422],\n", " 'xyz_coords': [-3.399541855, 260.233062744, -17.219060898]}]},\n", " {'frame': 353,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.902187448798787,\n", " 1.645946525418384,\n", " -177.99580828081034],\n", " 'xyz_coords': [-3.383351088, 258.883880615, -17.161464691]}]},\n", " {'frame': 354,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.8722724076294104,\n", " 1.6159592609504427,\n", " -178.31079696883913],\n", " 'xyz_coords': [-3.362282991, 257.538543701, -17.116769791]}]},\n", " {'frame': 355,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.8246743297863124,\n", " 1.7773034817345101,\n", " -178.612569240559],\n", " 'xyz_coords': [-3.342396259, 256.160552979, -17.065944672]}]},\n", " {'frame': 356,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.8703146614420763,\n", " 1.9509217942975372,\n", " -178.8674943482863],\n", " 'xyz_coords': [-3.320409298, 254.800216675, -17.038511276]}]},\n", " {'frame': 357,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.89893312433914,\n", " 1.9470889196058538,\n", " -179.12901856498414],\n", " 'xyz_coords': [-3.301895142, 253.445617676, -17.005653381]}]},\n", " {'frame': 358,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.9558783193245,\n", " 1.9232451201411929,\n", " -179.33714722902758],\n", " 'xyz_coords': [-3.275055408, 252.084701538, -16.985042572]}]},\n", " {'frame': 359,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.965074122791214,\n", " 1.8699570882272445,\n", " -179.49579649421372],\n", " 'xyz_coords': [-3.25212431, 250.727905273, -16.967561722]}]},\n", " {'frame': 360,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.9542072524376795,\n", " 1.6930283516209155,\n", " -179.64597349438188],\n", " 'xyz_coords': [-3.229992151, 249.358840942, -16.951469421]}]},\n", " {'frame': 361,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.916621202905816,\n", " 1.5624660005215192,\n", " -179.78074893771165],\n", " 'xyz_coords': [-3.2080791, 247.991378784, -16.94373703]}]},\n", " {'frame': 362,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.8785904131612168,\n", " 1.6981591429357497,\n", " -179.9104369609295],\n", " 'xyz_coords': [-3.190382004, 246.611862183, -16.927930832]}]},\n", " {'frame': 363,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.922406791812155,\n", " 1.8043982701270036,\n", " 179.99557067900218],\n", " 'xyz_coords': [-3.172147036, 245.234130859, -16.921962738]}]},\n", " {'frame': 364,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.9100430196383957,\n", " 1.8250684037227316,\n", " 179.94553932805354],\n", " 'xyz_coords': [-3.150076389, 243.857498169, -16.914955139]}]},\n", " {'frame': 365,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.9892543121666963,\n", " 1.8466756784884633,\n", " 179.94840568338876],\n", " 'xyz_coords': [-3.127025843, 242.46144104, -16.915813446]}]},\n", " {'frame': 366,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.04155898799163, 1.8267508136411397, 179.9827913350745],\n", " 'xyz_coords': [-3.09859705, 241.073883057, -16.912239075]}]},\n", " {'frame': 367,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.1295470399937337,\n", " 1.7302127928598974,\n", " -179.9775103278026],\n", " 'xyz_coords': [-3.080907106, 239.689315796, -16.913217545]}]},\n", " {'frame': 368,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.1957724823298244,\n", " 1.6237891717950745,\n", " -179.93617446785066],\n", " 'xyz_coords': [-3.057740211, 238.283950806, -16.901191711]}]},\n", " {'frame': 369,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.2981600855575612,\n", " 1.69469916299058,\n", " -179.87287252404627],\n", " 'xyz_coords': [-3.039555311, 236.877319336, -16.896366119]}]},\n", " {'frame': 370,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.3134334437046467,\n", " 1.8451011992633712,\n", " -179.80863606584188],\n", " 'xyz_coords': [-3.012426138, 235.470108032, -16.880634308]}]},\n", " {'frame': 371,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.2707046753367552,\n", " 1.9013847319630055,\n", " -179.73429469646308],\n", " 'xyz_coords': [-2.988728285, 234.057540894, -16.877765656]}]},\n", " {'frame': 372,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.1789366655366216,\n", " 1.9340672546183582,\n", " -179.67746441939525],\n", " 'xyz_coords': [-2.962264538, 232.659912109, -16.859666824]}]},\n", " {'frame': 373,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.0690985083322664,\n", " 1.899585969392696,\n", " -179.64186206469324],\n", " 'xyz_coords': [-2.934557676, 231.254333496, -16.841890335]}]},\n", " {'frame': 374,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.9728857580232035,\n", " 1.8631543709159455,\n", " -179.62696801299452],\n", " 'xyz_coords': [-2.907088757, 229.840774536, -16.819972992]}]},\n", " {'frame': 375,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.0036801082526705,\n", " 1.7857902192882888,\n", " -179.61328446600558],\n", " 'xyz_coords': [-2.889022589, 228.428451538, -16.809064865]}]},\n", " {'frame': 376,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.0183910472121385,\n", " 1.6704598641882262,\n", " -179.594671096647],\n", " 'xyz_coords': [-2.861954689, 227.012237549, -16.796977997]}]},\n", " {'frame': 377,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.0864291073612358,\n", " 1.7297329326047912,\n", " -179.57794871727472],\n", " 'xyz_coords': [-2.848429203, 225.596588135, -16.786281586]}]},\n", " {'frame': 378,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.0790967357348276,\n", " 1.773533025425639,\n", " -179.55843136343069],\n", " 'xyz_coords': [-2.828167439, 224.175094604, -16.766901016]}]},\n", " {'frame': 379,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.050839729147161,\n", " 1.8114464519979965,\n", " -179.55525052636455],\n", " 'xyz_coords': [-2.800728083, 222.733047485, -16.746273041]}]},\n", " {'frame': 380,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.0035783985991444,\n", " 1.8848953661580772,\n", " -179.56399614320313],\n", " 'xyz_coords': [-2.784346342, 221.302505493, -16.72195816]}]},\n", " {'frame': 381,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.0771637283075846,\n", " 1.8473614368215372,\n", " -179.58099391056456],\n", " 'xyz_coords': [-2.75673604, 219.85899353, -16.705783844]}]},\n", " {'frame': 382,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.0422919896551357,\n", " 1.7733421101685622,\n", " -179.579230120223],\n", " 'xyz_coords': [-2.728898048, 218.421051025, -16.684505463]}]},\n", " {'frame': 383,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.16673568935943,\n", " 1.8075873287730495,\n", " -179.54589320543218],\n", " 'xyz_coords': [-2.708491802, 216.970916748, -16.671417236]}]},\n", " {'frame': 384,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.195458906527444,\n", " 1.9312694968116353,\n", " -179.54140109068337],\n", " 'xyz_coords': [-2.687223673, 215.521942139, -16.653297424]}]},\n", " {'frame': 385,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.220762780018301,\n", " 1.8608463960627044,\n", " -179.53926771335975],\n", " 'xyz_coords': [-2.660978317, 214.072937012, -16.63571167]}]},\n", " {'frame': 386,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.2074211057239954,\n", " 1.7185395250537594,\n", " -179.55976782010265],\n", " 'xyz_coords': [-2.639802694, 212.618713379, -16.614379883]}]},\n", " {'frame': 387,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.216999367702726,\n", " 1.7355711386901986,\n", " -179.56367561448818],\n", " 'xyz_coords': [-2.61591959, 211.154800415, -16.598270416]}]},\n", " {'frame': 388,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.1930913887795507,\n", " 1.7256498620364127,\n", " -179.5558431722488],\n", " 'xyz_coords': [-2.601182222, 209.684906006, -16.582042694]}]},\n", " {'frame': 389,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.1868768027737677,\n", " 1.639683646350878,\n", " -179.56407156173285],\n", " 'xyz_coords': [-2.57765007, 208.228973389, -16.562082291]}]},\n", " {'frame': 390,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.1263388271258927,\n", " 1.723627893751499,\n", " -179.54794233563123],\n", " 'xyz_coords': [-2.555302858, 206.760681152, -16.544754028]}]},\n", " {'frame': 391,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.078237775897662,\n", " 1.8294545526730455,\n", " -179.5596114902977],\n", " 'xyz_coords': [-2.533575535, 205.28314209, -16.521953583]}]},\n", " {'frame': 392,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.0238827362322227,\n", " 1.835506201764444,\n", " -179.55914947264662],\n", " 'xyz_coords': [-2.508204937, 203.806381226, -16.496244431]}]},\n", " {'frame': 393,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.0838118926527187,\n", " 1.785753740132584,\n", " -179.54746539777227],\n", " 'xyz_coords': [-2.488462925, 202.318557739, -16.481742859]}]},\n", " {'frame': 394,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.0851195711853046,\n", " 1.7808260813959795,\n", " -179.545634704041],\n", " 'xyz_coords': [-2.465270996, 200.845108032, -16.462884903]}]},\n", " {'frame': 395,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.1344294649994167,\n", " 1.88001781024324,\n", " -179.56864550021783],\n", " 'xyz_coords': [-2.446104288, 199.37286377, -16.448390961]}]},\n", " {'frame': 396,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.1221836161758083,\n", " 2.035542389299365,\n", " -179.61367801315038],\n", " 'xyz_coords': [-2.424544096, 197.889984131, -16.428527832]}]},\n", " {'frame': 397,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-3.046007500095521,\n", " 2.059107249386814,\n", " -179.6853840612038],\n", " 'xyz_coords': [-2.399994612, 196.441604614, -16.409934998]}]},\n", " {'frame': 398,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.999390812693269, 2.0454763891517165, -179.73245683146],\n", " 'xyz_coords': [-2.372132778, 194.966171265, -16.398878098]}]},\n", " {'frame': 399,\n", " 'poses': [{'camera_id': 0,\n", " 'euler_angles': [-2.9739802615108935,\n", " 2.092353575494336,\n", " -179.78260116458497],\n", " 'xyz_coords': [-2.349857807, 193.513824463, -16.387588501]}]}]" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "json_traj[\"data\"][300:400]" ] }, { "cell_type": "code", "execution_count": 18, "id": "ec96c736", "metadata": {}, "outputs": [], "source": [ "with open('cameraTraj_UE4_format.json', 'w') as f:\n", " json.dump(json_traj, f, indent=2)" ] }, { "cell_type": "code", "execution_count": null, "id": "13093b0d", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "e9095c85", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.10" } }, "nbformat": 4, "nbformat_minor": 5 }