| 31 | |
| 32 | |
| 33 | def check_small_errors_or_exit( |
| 34 | dataset_name: str, |
| 35 | max_rotation_error: float, |
| 36 | max_proj_center_error: float, |
| 37 | expected_num_images: float, |
| 38 | errors_csv_path: str, |
| 39 | ) -> None: |
| 40 | logging.info(f"Evaluating errors for {dataset_name}") |
| 41 | |
| 42 | error = False |
| 43 | with open(errors_csv_path) as fid: |
| 44 | num_images = 0 |
| 45 | for line in fid: |
| 46 | line = line.strip() |
| 47 | if len(line) == 0 or line.startswith("#"): |
| 48 | continue |
| 49 | rotation_error, proj_center_error = map(float, line.split(",")) |
| 50 | num_images += 1 |
| 51 | if rotation_error > max_rotation_error: |
| 52 | logging.info( |
| 53 | "Exceeded rotation error threshold:", rotation_error |
| 54 | ) |
| 55 | error = True |
| 56 | if proj_center_error > max_proj_center_error: |
| 57 | logging.info( |
| 58 | "Exceeded projection center error threshold:", |
| 59 | proj_center_error, |
| 60 | ) |
| 61 | error = True |
| 62 | |
| 63 | if num_images != expected_num_images: |
| 64 | logging.error("Unexpected number of images:", num_images) |
| 65 | error = True |
| 66 | |
| 67 | if error: |
| 68 | sys.exit(1) |
| 69 | |
| 70 | |
| 71 | def process_dataset(args: argparse.Namespace, dataset_name: str) -> None: |