diff --git a/zesje/images.py b/zesje/images.py index 06eef07709796bda914b888299c73a5d97842ab0..d4afe7661fc55d9a67960074da430f9b68eed2e6 100644 --- a/zesje/images.py +++ b/zesje/images.py @@ -59,7 +59,7 @@ def fix_corner_markers(corner_keypoints, shape): """ if len(corner_keypoints) == 4 or len(corner_keypoints) < 3: - return corner_keypoints + raise RuntimeError("Fewer then 3 corner markers found") x_sep = shape[1] / 2 y_sep = shape[0] / 2 diff --git a/zesje/pregrader.py b/zesje/pregrader.py index 37c3535cbf5318523b8bdad5e0ff5b47eb000fc2..4954bc8a7d2083f782ce0c03e42c74284e2e12f7 100644 --- a/zesje/pregrader.py +++ b/zesje/pregrader.py @@ -22,7 +22,6 @@ def add_feedback_to_solution(sub, exam, page, page_img, corner_keypoints): """ problems_on_page = [problem for problem in exam.problems if problem.widget.page == page] - # TODO: What if less than 3 keypoints are found? top_left_point, fixed_corner_keypoints = fix_corner_markers(corner_keypoints, page_img.shape) for problem in problems_on_page: diff --git a/zesje/scans.py b/zesje/scans.py index ac0be8e012e25df255aa31bef4948780eefd0ed0..4d3e1c5b963ef2b3432ad95c8a62c712e550d2ac 100644 --- a/zesje/scans.py +++ b/zesje/scans.py @@ -339,7 +339,12 @@ def process_page(image_data, exam_config, output_dir=None, strict=False): return True, "Testing, image not saved and database not updated." sub, exam = update_database(image_path, barcode) - add_feedback_to_solution(sub, exam, barcode.page, image_array, corner_keypoints) + + try: + add_feedback_to_solution(sub, exam, barcode.page, image_array, corner_keypoints) + except RuntimeError as e: + if strict: + return False, str(e) if barcode.page == 0: description = guess_student(