You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

createhandletrace.py 1.0KB

123456789101112131415161718192021222324252627282930313233
  1. import os, sys
  2. import pandas as pd
  3. import numpy as np
  4. sys.path.append('..')
  5. import modules.coordsi as csi
  6. import math
  7. import time
  8. # initialize root path
  9. root = './List_Data_Call/'
  10. summary_1 = csi.summaryOriginCoord(root, camid=1)
  11. #make a loop for each index
  12. for index, row in summary_1.iterrows():
  13. timestamp = []
  14. start_time = time.time()
  15. df = csi.readCam(os.path.join(index,'cam1.csv'))
  16. df = csi.convertToSI(df, 3.5, 1.5, 3.4)
  17. df = csi.getVelocity(df)
  18. df = csi.getAcceleration(df)
  19. df = csi.getFullTrace(df,row['approx_total_frame'] )
  20. df = csi.addValidDetection(df, 25.0)
  21. try:
  22. df.to_csv(os.path.join('./handletrace/', index[17:]+'.csv'), index=False)
  23. #save spend time and index of summary_1 in timestamp list
  24. timestamp.append([index, time.time() - start_time])
  25. print([index, time.time() - start_time])
  26. except Exception as e:
  27. print(e)
  28. continue
  29. #save timestamp list to csv file
  30. pd.DataFrame(timestamp, columns=['index', 'time']).to_csv('./handletrace/timestamp.csv', index=False)