Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
zesje
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Works on my machine
zesje
Commits
f193b86f
Commit
f193b86f
authored
5 years ago
by
Ruben Young On
Browse files
Options
Downloads
Patches
Plain Diff
Refactored pregrader
parent
7b1a3df7
No related branches found
Branches containing commit
No related tags found
1 merge request
!17
Add pregrading
Pipeline
#17933
passed with warnings
5 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
zesje/pregrader.py
+15
-11
15 additions, 11 deletions
zesje/pregrader.py
with
15 additions
and
11 deletions
zesje/pregrader.py
+
15
−
11
View file @
f193b86f
...
...
@@ -13,7 +13,7 @@
import
cv2
import
numpy
as
np
from
zesje.database
import
db
,
Solution
,
ProblemWidget
from
zesje.database
import
db
,
Solution
,
ProblemWidget
,
Problem
from
zesje.images
import
guess_dpi
,
get_box
,
fix_corner_markers
...
...
@@ -27,24 +27,28 @@ def add_feedback_to_solution(page, page_img, corner_keypoints):
barcode: data from the barcode on the page
corner_keypoints: locations of the corner keypoints
"""
widgets
=
ProblemWidget
.
query
.
filter
(
ProblemWidget
.
page
==
page
).
all
()
problem_widgets
=
ProblemWidget
.
query
.
filter
(
ProblemWidget
.
page
==
page
).
all
()
problems_on_page
=
[
widget
.
problem
for
widget
in
problem_widgets
]
problems_on_page
=
[
widget
.
problem
for
widget
in
widgets
]
fixed_corner_keypoints
=
fix_corner_markers
(
corner_keypoints
,
page_img
.
shape
)
corner_keypoints
=
fix_corner_markers
(
corner_keypoints
,
page_img
.
shape
)
# TODO: It is not exactly known which corner marker is the top left one
# TODO: Also, what do if less than 3 keypoints are found?
top_left_point
=
sorted
(
fixed_corner_keypoints
,
key
=
lambda
x
:
x
[
0
])[
0
]
if
fixed_corner_keypoints
else
[]
for
problem
in
problems_on_page
:
sol
=
Solution
.
query
.
filter
(
Solution
.
problem_id
==
problem
.
id
).
one_or_none
()
for
mc_option
in
problem
.
mc_options
:
if
mc_option
:
sol
=
Solution
.
query
.
filter
(
Solution
.
problem_id
==
problem
.
id
).
one_or_none
()
box
=
(
mc_option
.
x
,
mc_option
.
y
)
box
=
(
mc_option
.
x
,
mc_option
.
y
)
# TODO: Assume the minimal x value will be of the
top
left
corner
top_left
=
sorted
(
corner_keypoints
,
key
=
lambda
x
:
x
[
0
])[
0
]
if
box_is_filled
(
box
,
page_img
,
top
_
left
_point
):
sol
.
feedback
=
mc_option
.
feedback
if
box_is_filled
(
box
,
page_img
,
top_left
)
:
if
mc_option
.
label
:
sol
.
feedback
.
text
=
mc_option
.
label
db
.
session
.
commit
()
db
.
session
.
commit
()
def
box_is_filled
(
box
,
page_img
,
corner_keypoints
,
marker_margin
=
72
/
2.54
,
threshold
=
225
,
cut_padding
=
0.1
,
box_size
=
11
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment