def standardizeGyro(self, isTrain): print('standardizing gyro') normPath = '../Norms/' + branchName() + '_' + self.dsName + '_' + self.subType if isTrain: gyroMean = np.mean(self.dw_gyro, axis=0) gyroStd = np.std(self.dw_gyro, axis=0) np.savetxt(normPath + 'gyroMean.txt', gyroMean) np.savetxt(normPath + 'gyroStd.txt', gyroStd) else: gyroMean = np.loadtxt(normPath + 'gyroMean.txt') gyroStd = np.loadtxt(normPath + 'gyroStd.txt') self.gyro_standard = self.dw_gyro - gyroMean self.gyro_standard = np.divide(self.gyro_standard, gyroStd).astype(np.float32)
def standardize(self, isTrain): print('standardizing acc') normPath = 'Norms/' + branchName() + '_' + self.dsName + '_' + self.subType if isTrain: accMean = np.mean(self.accdt_gnd, axis=0) accStd = np.std(self.accdt_gnd, axis=0) np.savetxt(normPath + '_img_accMean.txt', accMean) np.savetxt(normPath + '_img_accStd.txt', accStd) else: accMean = np.loadtxt(normPath + '_img_accMean.txt') accStd = np.loadtxt(normPath + '_img_accStd.txt') self.acc_gnd_standard = self.accdt_gnd - accMean self.acc_gnd_standard = np.divide(self.acc_gnd_standard, accStd).astype(np.float32)
def standardizeImgs(self, isTrain): print('preparing to standardize imgs') mean = np.mean(self.imgs, axis=(0, 2, 3)) std = np.std(self.imgs, axis=(0, 2, 3)) normPath = '../Norms/' + branchName() + '_' + self.dsName + '_' + self.subType if isTrain: np.savetxt(normPath + '_img_mean.txt', mean) np.savetxt(normPath + '_img_std.txt', std) else: mean = np.loadtxt(normPath + '_img_mean.txt') std = np.loadtxt(normPath + '_img_std.txt') if self.dsName == 'euroc': mean = np.reshape(mean, (1,1)) std = np.reshape(std, (1,1)) # standardize imgs print('standardizing imgs') mean = mean.astype(np.float32) std = std.astype(np.float32) for i in range(0, self.imgs.shape[1]): self.imgs[:, i, :, :] = (self.imgs[:, i, :, :] - mean[i])/std[i] print('done standardizing imgs')