import cv2 import math def CalculateWidth(size, h, w, imgCropped, imgFixed): c = size / h wCal = math.ceil(c * w) imgResized = cv2.resize(imgCropped, (wCal, size)) wGap = math.ceil((size - wCal) / 2) imgFixed[:, wGap:wCal + wGap] = imgResized def CalculateHeight(size, h, w, imgCropped, imgFixed): c = size / w hCal = math.ceil(c * h) imgResized = cv2.resize(imgCropped, (size, hCal)) hGap = math.ceil((size - hCal) / 2) imgFixed[hGap:hCal + hGap, :] = imgResized def GetPrediction(classifier, imgFixed): prediction, index = classifier.getPrediction(imgFixed, draw=False) return prediction, index def GetLabels(path): letters = [] with open(path, 'r') as file: for line in file: parts = line.strip().split(' ') if len(parts) == 2: letter = parts[1] letters.append(letter) return letters