Repository for M.A.I.L system's analysis server.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

mailextract_01.py 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import os
  2. import sys
  3. import numpy
  4. import subprocess
  5. import pandas as pd
  6. import time
  7. SOURCE_DIR = '/home/mc365/sources/'
  8. STROAGE_DIR = '/hdd/'
  9. LOG_EXTRACT = '/log_extract.txt'
  10. #NOTE: CHANGE CFG, WEIGHT, .data
  11. CFG_FILE = 'yolov4_7gpu.cfg'
  12. WEIGHT_FILE = 'yolov4_7gpu_last.weights'
  13. DATA_FILE = 'obj.data'
  14. FRAME_COUNTER = 0
  15. N_OF_FRAME = 1800
  16. SURGEON_DIR = os.path.abspath(STROAGE_DIR+os.listdir('/hdd/')[0])
  17. CALL_DEPTH = ['python3',SOURCE_DIR+'depthsensing.py', '-c', SOURCE_DIR+CFG_FILE, '-w', SOURCE_DIR+WEIGHT_FILE, '-m', SOURCE_DIR+DATA_FILE]
  18. #print(SURGEON_DIR)
  19. def extract_surgeon ():
  20. svo1list = [file for file in os.listdir(os.path.abspath(SURGEON_DIR)) if file.endswith('1.svo')]
  21. svo1list= sorted(svo1list)
  22. del svo1list[-1]
  23. for svo in svo1list:
  24. REST_OF_CALL_DEPTH = ['-s',SURGEON_DIR+'/'+svo, '-o', SURGEON_DIR+'/'+svo[:5]+'.csv']
  25. subprocess.call(CALL_DEPTH+REST_OF_CALL_DEPTH)
  26. def concat_csv():
  27. csv1list = [file for file in os.listdir(os.path.abspath(SURGEON_DIR)) if file.endswith('1.csv')]
  28. csv1list = sorted(csv1list)
  29. fc = FRAME_COUNTER
  30. nf = N_OF_FRAME
  31. conc_df = pd.DataFrame(data={'x': [], 'y': [], 'z': [], 'frame': []})
  32. for csv in csv1list:
  33. df = pd.read_csv(os.path.join(SURGEON_DIR,csv), header=0)
  34. df['frame'] = df['frame'] + fc
  35. conc_df = pd.concat([conc_df,df])
  36. fc += nf
  37. conc_df.to_csv(os.path.join(SURGEON_DIR,'cam1.csv'), index=False)
  38. def concat_csv_with_nms():
  39. csv1list = [file for file in os.listdir(os.path.abspath(SURGEON_DIR)) if file.endswith('1_nms.csv')]
  40. csv1list = sorted(csv1list)
  41. fc = FRAME_COUNTER
  42. nf = N_OF_FRAME
  43. conc_df = pd.DataFrame(data={'x': [], 'y': [], 'z': [], 'nms':[],'frame': []})
  44. for csv in csv1list:
  45. df = pd.read_csv(os.path.join(SURGEON_DIR,csv), header=0)
  46. df['frame'] = df['frame'] + fc
  47. conc_df = pd.concat([conc_df,df])
  48. fc += nf
  49. conc_df.to_csv(os.path.join(SURGEON_DIR,'cam1_nms.csv'), index=False)
  50. def log_write():
  51. exttime = time.localtime()
  52. csv1list = [file for file in os.listdir(os.path.abspath(SURGEON_DIR)) if file.endswith('1.csv')]
  53. with open (os.path.abspath(SURGEON_DIR+LOG_EXTRACT), "a") as log_extract:
  54. log_extract.write("\n[EXTRACT] EXTRACT %d svo files finishied at %04d/%02d/%02d %02d:%02d:%02d" % (len(csv1list)-1,exttime.tm_year, exttime.tm_mon, exttime.tm_mday, exttime.tm_hour, exttime.tm_min, exttime.tm_sec))
  55. def main():
  56. extract_surgeon()
  57. concat_csv()
  58. concat_csv_with_nms()
  59. log_write()
  60. if __name__ == '__main__':
  61. main()