Skip to content

Commit

Permalink
update file manegenment
Browse files Browse the repository at this point in the history
  • Loading branch information
akawincent committed Jun 23, 2023
1 parent 49af81a commit 87b5aff
Show file tree
Hide file tree
Showing 35 changed files with 49 additions and 21 deletions.
Binary file added __pycache__/path.cpython-310.pyc
Binary file not shown.
Binary file modified __pycache__/record.cpython-310.pyc
Binary file not shown.
Binary file modified __pycache__/utils.cpython-310.pyc
Binary file not shown.
13 changes: 13 additions & 0 deletions data/groundtruth.tum
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
1687525013245793 0.008737427182495594 0.006640564650297165 0.00012093909754185006 -0.004832196049392223 -0.061782412230968475 0.0027675253804773092 0.9980741143226624
1687525013295912 0.01995055563747883 0.009509846568107605 0.0003808395704254508 -0.0020751953125 -0.05316116660833359 0.006357039324939251 0.9985635876655579
1687525013346037 0.03906664997339249 0.014902551658451557 0.0016926164971664548 -0.0029398424085229635 -0.05186523124575615 0.023785237222909927 0.9983664751052856
1687525013396035 0.05986426770687103 0.02006983384490013 0.003779127961024642 -0.001895040855742991 -0.04314214363694191 0.03892818093299866 0.9983084201812744
1687525013446162 0.08195693045854568 0.024347485974431038 0.007168796379119158 -0.00042286395910196006 -0.03884752094745636 0.055935781449079514 0.9976782202720642
1687525013496294 0.10118470340967178 0.028867188841104507 0.009785447269678116 -0.0015000251587480307 -0.033006422221660614 0.06831085681915283 0.9971168041229248
1687525013546294 0.11866006255149841 0.032496560364961624 0.011424116790294647 -0.004214520566165447 -0.023416191339492798 0.07763681560754776 0.9966977834701538
1687525013596414 0.13562598824501038 0.03434262424707413 0.013306362554430962 -0.004599961917847395 -0.00859274435788393 0.08632554858922958 0.9962193369865417
1687525013646537 0.14879731833934784 0.03638317435979843 0.013588262721896172 -0.0028549842536449432 -0.001226791413500905 0.09578070789575577 0.9953976273536682
1687525013679925 0.15768125653266907 0.036847569048404694 0.01377336960285902 -0.0024475022219121456 0.004232162144035101 0.09785974025726318 0.9951882362365723
1687525013729917 0.1665954887866974 0.03779984638094902 0.013884707354009151 0.00040486143552698195 0.008002824150025845 0.09748756885528564 0.995204508304596
1687525013780040 0.17436182498931885 0.03799871355295181 0.013407713733613491 0.003041976597160101 0.013109351508319378 0.09817997366189957 0.9950776696205139
1687525013830167 0.1814393848180771 0.0376175120472908 0.012344763614237309 0.005322321783751249 0.01877027004957199 0.09518643468618393 0.9952682852745056
Binary file added data/images/image_0/1687525013245793.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_0/1687525013295912.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_0/1687525013346037.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_0/1687525013396035.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_0/1687525013446162.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_0/1687525013496294.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_0/1687525013546294.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_0/1687525013596414.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_0/1687525013646537.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_0/1687525013679925.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_0/1687525013729917.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_0/1687525013780040.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_0/1687525013830167.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_1/1687525013245793.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_1/1687525013295912.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_1/1687525013346037.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_1/1687525013396035.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_1/1687525013446162.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_1/1687525013496294.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_1/1687525013546294.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_1/1687525013596414.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_1/1687525013646537.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_1/1687525013679925.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_1/1687525013729917.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/image_1/1687525013780040.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions data/times.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
1687525013.245793
1687525013.295912
1687525013.346037
1687525013.396035
1687525013.446162
1687525013.496294
1687525013.546294
1687525013.596414
1687525013.646537
1687525013.679925
1687525013.729917
1687525013.780040
1687525013.830167
29 changes: 14 additions & 15 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,42 @@
import os
import glob
import time
import ogl_viewer.tracking_viewer as gl
import path
import cv2
import numpy as np
import pyzed.sl as sl
import ogl_viewer.tracking_viewer as gl
from record import Recorder
from utils import Tools

if __name__ == '__main__':
# Clear file generated before
if( os.path.isfile("groundtruth.tum")):
os.remove('groundtruth.tum')
print("Groundtruth file Deleted successfully")
## Clear file generated before
if( os.path.isfile( path.gt_file_path ) ):
os.remove( path.gt_file_path )
print( "Groundtruth file Deleted successfully" )
else:
print("Groundtruth File does not exist")
print( "Groundtruth File does not exist" )

if( os.path.isfile("times.txt")):
os.remove('times.txt')
print("Timestamp file Deleted successfully")
if( os.path.isfile( path.times_file_path ) ):
os.remove( path.times_file_path )
print( "Timestamp file Deleted successfully" )
else:
print("Timestamp File does not exist")
for image_file in glob.glob("images/image_0/*"):
print( "Timestamp File does not exist" )

for image_file in glob.glob( path.image0_file_path + '*' ):
if(image_file.__len__() != 0):
os.remove(image_file)
print("delete"+str(image_file))
else:
print("image_0 is Already empty")

for image_file in glob.glob("images/image_1/*"):
for image_file in glob.glob( path.image1_file_path + '*' ):
if(image_file.__len__() != 0):
os.remove(image_file)
print("delete"+str(image_file))
else:
print("image_1 is Already empty")



## Initialize camera params
# Coordinate system is ROS frame
camera_params = sl.InitParameters(
Expand Down
Binary file modified ogl_viewer/__pycache__/tracking_viewer.cpython-310.pyc
Binary file not shown.
Binary file modified ogl_viewer/__pycache__/zed_model.cpython-310.pyc
Binary file not shown.
4 changes: 4 additions & 0 deletions path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gt_file_path = ".\\data\\groundtruth.tum"
times_file_path = ".\\data\\times.txt"
image0_file_path = ".\\data\\images\\image_0\\"
image1_file_path = ".\\data\\images\\image_1\\"
11 changes: 5 additions & 6 deletions record.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import os
import cv2

import path
class Recorder:

# Write data in file
def record_pose_data( data ):
timestamp = data[0]
[tx,ty,tz] = data[1:4:1]
[qx,qy,qz,qw] = data[4:8:1]
with open('groundtruth.tum','a') as file_handle:
with open( path.gt_file_path ,'a') as file_handle:
file_handle.write("{0} {1} {2} {3} {4} {5} {6} {7}\n".format(timestamp,
tx,
ty,
Expand All @@ -20,7 +19,7 @@ def record_pose_data( data ):
file_handle.close()

def record_timestamp(timestamp):
with open('times.txt','a') as file_handle:
with open( path.times_file_path ,'a') as file_handle:
timestamp = str(round(timestamp * 1e-6,6))
if(timestamp.__len__() == 16):
timestamp = timestamp + str('0')
Expand All @@ -31,7 +30,7 @@ def record_timestamp(timestamp):
def record_img_data( LeftImg , RightImg , Timestamp ):
left_view = LeftImg
right_view = RightImg
left_img_save_path = os.path.join("./images/image_0","{0}.jpg".format(Timestamp))
right_img_save_path = os.path.join("./images/image_1","{0}.jpg".format(Timestamp))
left_img_save_path = os.path.join( path.image0_file_path ,"{0}.jpg".format(Timestamp))
right_img_save_path = os.path.join( path.image1_file_path ,"{0}.jpg".format(Timestamp))
cv2.imwrite( left_img_save_path , left_view)
cv2.imwrite( right_img_save_path , right_view)

0 comments on commit 87b5aff

Please sign in to comment.