Skip to content
Snippets Groups Projects
Commit 0f8706f7 authored by Ruben Young On's avatar Ruben Young On
Browse files

Simplified fix_corner_markers

parent 5155c01a
No related branches found
No related tags found
1 merge request!17Add pregrading
Pipeline #17975 failed
......@@ -54,8 +54,6 @@ def fix_corner_markers(corner_keypoints, shape):
-------
corner_keypoints :
A list of four corner markers.
top_left : tuple
Coordinates of the top left corner marker
"""
if len(corner_keypoints) == 4:
......@@ -78,7 +76,6 @@ def fix_corner_markers(corner_keypoints, shape):
# Top left point is missing
(dx, dy) = tuple(map(sub, top_right[0], bottom_right[0]))
missing_point = tuple(map(add, bottom_left[0], (dx, dy)))
top_left = [missing_point]
elif not bottom_left:
# Bottom left point is missing
......@@ -95,7 +92,8 @@ def fix_corner_markers(corner_keypoints, shape):
(dx, dy) = tuple(map(sub, top_left[0], bottom_left[0]))
missing_point = tuple(map(sub, top_right[0], (dx, dy)))
return top_left[0], corner_keypoints + [missing_point]
corner_keypoints.append(missing_point)
return corner_keypoints
def box_is_filled(image_array, box_coords, padding=0.3, threshold=150, pixels=False):
......
......@@ -22,7 +22,11 @@ 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]
top_left_point, fixed_corner_keypoints = fix_corner_markers(corner_keypoints, page_img.shape)
fixed_corners = fix_corner_markers(corner_keypoints, page_img.shape)
x_min = min(point[0] for point in fixed_corners)
y_min = min(point[1] for point in fixed_corners)
top_left_point = (x_min, y_min)
for problem in problems_on_page:
sol = Solution.query.filter(Solution.problem_id == problem.id, Solution.submission_id == sub.id).one_or_none()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment