HwHDRBuilder.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import os, json
  2. import numpy as np
  3. from . import Builder, ImageDB, utils
  4. class HwHDRBuilder(Builder.Builder):
  5. """description of class"""
  6. def __init__(self):
  7. super().__init__()
  8. def compute(self,db, src):
  9. super().compute(db,src)
  10. # recover data from config
  11. imagePATH = self.config["imagePATH"]
  12. cvsFilePATH = self.config["cvsFilePATH"]
  13. # get database compenents
  14. components = self.config['components']
  15. # build is done according to a source
  16. for c in components:
  17. if src in c: configSRC= c
  18. # source path
  19. srcPath = imagePATH + configSRC[src]['path']
  20. # get file in source path
  21. l = os.listdir(srcPath)
  22. # get only files with right name
  23. srcList = []
  24. for f in l:
  25. if utils.checkString(f,configSRC[src]) : srcList.append(f)
  26. # srcList contains src file with correct format
  27. # check other compoents
  28. requiredFiles = []
  29. # for all file in scrList (source file)
  30. for srcfile in srcList:
  31. # listPerSourceFile
  32. listPerSourceFile = []
  33. # get number
  34. n = utils.filename_to_number(srcfile,configSRC[src])
  35. listPerSourceFile.append(configSRC[src]['path']+srcfile)
  36. # for other components
  37. for comp in components:
  38. if not src in comp: # if not the source
  39. currentConfig = comp
  40. # get name of compenent
  41. k = list(currentConfig.keys())[0]
  42. # get config compoenent
  43. kv = currentConfig[k]
  44. listPerSourceFile.extend(utils.number_to_filenames(n,kv))
  45. requiredFiles.append(listPerSourceFile)
  46. # save as csv file
  47. np.savetxt( db.csvFileName, requiredFiles, delimiter=";",fmt="%s",encoding="utf8")
  48. # update db in db
  49. db.db = requiredFiles