def dataDirInit(): path = FileNameUtil.getBasedirname(__file__) saveVariableDirname = FileNameUtil.getDirname( path, gps.saveVariableDirnameList) logDirname = FileNameUtil.getDirname(path, gps.logDirnameList) if not FileNameUtil.fileExisted(saveVariableDirname): os.makedirs(saveVariableDirname) if not FileNameUtil.fileExisted(logDirname): os.makedirs(logDirname)
def get_batch_gasmeter_digit_area_from_filename(self, filename, batchsize): """ 根据燃气表图片文件名,获得改燃气表数字区域的数据并返回。主要功能用来预测单张图片数据 :param filename: """ if not FileNameUtil.fileExisted(filename): raise ValueError("%s 文件不存在") image = cv2.imread(filename) image = ImageTool.getGasmeterAreaData(image) image = cv2.resize(image, (self._picBoxWidth, self._picBoxHeight)) image = np.array(image, dtype=np.float32).flatten() image = image.reshape((-1, image.shape[0])) batch_x = np.repeat(image, batchsize, 0) return batch_x