def __init__(self, name, trainingPath, testingPath, resultPath, histogramTypes, description="", numberRuns=1, maxk=10, trainingPerc=-1):
     self.name = name
     self.description = description
     self.runs = []
     self.numberRuns = numberRuns
     self.root = getPath(resultPath, name + "_" + self.getCurrentDateTime() )
     self.maxk = maxk
     self.histogramTypes = histogramTypes
     self.log = Log()
     self.trainingPerc = trainingPerc
     if self.trainingPerc != -1:
         self.testingPerc = 1 - self.trainingPerc
     self.datasets = {}
     if trainingPath == testingPath:
         for ht in self.histogramTypes:
             if isinstance(ht, int):
                 dataset = DataSet()
                 dataset.load(ht, trainingPath)
                 self.datasets[ht] = dataset
     else:
         for ht in self.histogramTypes:
             if isinstance(ht, int):
                 dataset = DataSetSeparate()
                 dataset.load(ht, trainingPath, testingPath)
                 self.datasets[ht] = dataset
    aux = ""
    cont = 1
    for label in results:
        aux = aux + "\n" + str(cont) + "." + str(label)
        cont+=1
    return aux

def getNPFromFile(f):
    return np.asarray(bytearray(f.read()), dtype=np.uint8)
     
     
#if __name__ == '__main__':
print("Preparing Leaf Search Engine...")
disks = generateDiskKernelsMasks(25) #used for naive
circumferences = generateDiskCircumferenceKernelsMasks(25)
dataset = DataSet()
dataset.load(C.HIST_HCoS, "/Users/maeotaku/Documents/DatasetsNon1/CostaRica/OnlyCamera/")
finder = FindK(dataset, C.KNN_DEFAULT, disks, circumferences)
print("Done.")

@route('/', method='POST')
def do_upload():
    try:
        aux = ""
        files = request.files
        for name in files:
            fileUpload = files[name]
            if fileUpload:
                file = fileUpload.file
                img = cv2.imdecode(getNPFromFile(file), cv2.CV_LOAD_IMAGE_UNCHANGED) # This is dangerous for big files
                #img = loadImage("/Users/maeotaku/Documents/Issues/Solved/WrongResize_IMG_6632.JPG")
    cont = 1
    for label in results:
        aux = aux + "\n" + str(cont) + "." + str(label)
        cont += 1
    return aux


def getNPFromFile(f):
    return np.asarray(bytearray(f.read()), dtype=np.uint8)


#if __name__ == '__main__':
print("Preparing Leaf Search Engine...")
disks = generateDiskKernelsMasks(25)  #used for naive
circumferences = generateDiskCircumferenceKernelsMasks(25)
dataset = DataSet()
dataset.load(C.HIST_HCoS,
             "/Users/maeotaku/Documents/DatasetsNon1/CostaRica/OnlyCamera/")
finder = FindK(dataset, C.KNN_DEFAULT, disks, circumferences)
print("Done.")


@route('/', method='POST')
def do_upload():
    try:
        aux = ""
        files = request.files
        for name in files:
            fileUpload = files[name]
            if fileUpload:
                file = fileUpload.file
 def loadDataset(self, ht, trainingPath):
     dataset = DataSet()
     dataset.load(ht, trainingPath)
     return dataset
 def loadDataset(self, ht, trainingPath):
     dataset = DataSet()
     dataset.load(ht, trainingPath)
     return dataset