def random_equi_rotation(image, gt_image): yaw = 2 * np.pi * random.random() roll = 2 * np.pi * (random.random() - 0.5) * 0.1 pitch = 2 * np.pi * (random.random() - 0.5) * 0.1 rotation_angles = np.array([yaw, roll, pitch]) image_res = np.zeros(image.shape) gtimage_res = np.zeros(gt_image.shape) extractEquirectangular_quick( True, image, image_res, Algebra.rotation_matrix(rotation_angles)) extractEquirectangular_quick( True, gt_image, gtimage_res, Algebra.rotation_matrix(rotation_angles)) gtimage_res = (gtimage_res + 0.1).astype(np.int32) if DEBUG: if not np.all(np.unique(gtimage_res) == np.unique(gt_image)): logging.warning("np.unique(gt_image ) {}".format( np.unique(gt_image))) logging.warning("np.unique(gt_image_res) {}".format( np.unique(gtimage_res))) for i in np.unique(gtimage_res): if i == 255: continue else: if i not in np.unique(gt_image): logging.error("Equirectangular removed classes.") assert i in np.unique(gt_image) return image_res, gtimage_res
def extractEquirectangular(wrap, source_image, result_image, euler_angles): extractEquirectangular_quick(wrap, source_image, result_image, Algebra.rotation_matrix(euler_angles))