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

Added function that fixes corner markers

parent 49da2683
No related branches found
No related tags found
1 merge request!17Add pregrading
Pipeline #17906 failed
......@@ -14,7 +14,7 @@ import cv2
import numpy as np
from zesje.database import db, Solution, Problem
from zesje.images import guess_dpi, get_box
from zesje.images import guess_dpi, get_box, fix_corner_markers
def add_feedback_to_solution(page, page_img, corner_keypoints):
......@@ -34,6 +34,8 @@ def add_feedback_to_solution(page, page_img, corner_keypoints):
box = (mc_option.x, mc_option.y)
corner_keypoints = fix_corner_markers(corner_keypoints, image=page_img, image_format=1)
# check if box is filled
if box_is_filled(box, page_img, corner_keypoints):
sol.feedback.append(mc_option.feedback)
......@@ -134,9 +136,9 @@ def box_is_filled(box, page_img, corner_keypoints, marker_margin=72/2.54, thresh
# if the found box is smaller than a certain threshold
# it means that we only found a little bit of white and the box is filled
res_x, res_y, *_ = res_rect.shape
if(res_x < 0.333 * box_size_px or res_y < 0.333 * box_size_px):
if res_x < 0.333 * box_size_px or res_y < 0.333 * box_size_px:
return True
return (np.average(res_rect) < 225)
return np.average(res_rect) < threshold
def box_is_filled(box, page_img, marker_position, marker_margin=72/2.54):
......
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