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
27ff7f5b
Commit
27ff7f5b
authored
5 years ago
by
Ruben Young On
Browse files
Options
Downloads
Patches
Plain Diff
Fixed call to box_is_filled, added some doc, changed where corner markers are fixed
parent
e25ffb23
No related branches found
Branches containing commit
No related tags found
1 merge request
!17
Add pregrading
Pipeline
#17931
passed with warnings
5 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
zesje/images.py
+2
-4
2 additions, 4 deletions
zesje/images.py
zesje/pregrader.py
+10
-8
10 additions, 8 deletions
zesje/pregrader.py
with
12 additions
and
12 deletions
zesje/images.py
+
2
−
4
View file @
27ff7f5b
"""
Utilities for dealing with images
"""
import
numpy
as
np
import
warnings
from
operator
import
sub
,
add
...
...
@@ -56,12 +57,9 @@ def fix_corner_markers(corner_keypoints, shape):
"""
if
len
(
corner_keypoints
)
==
4
:
if
len
(
corner_keypoints
)
==
4
or
len
(
corner_keypoints
)
<
3
:
return
corner_keypoints
if
len
(
corner_keypoints
)
<
3
:
raise
RuntimeError
(
"
Two or fewer corner markers detected
"
)
x_sep
=
shape
[
1
]
/
2
y_sep
=
shape
[
0
]
/
2
...
...
This diff is collapsed.
Click to expand it.
zesje/pregrader.py
+
10
−
8
View file @
27ff7f5b
...
...
@@ -25,22 +25,24 @@ def add_feedback_to_solution(page, page_img, corner_keypoints):
------
page_img: image of the page
barcode: data from the barcode on the page
corner_keypoints: locations of the corner keypoints
"""
widgets
=
ProblemWidget
.
query
.
filter
(
ProblemWidget
.
page
==
page
).
all
()
problems_on_page
=
[
widget
.
problem
for
widget
in
widgets
]
corner_keypoints
=
fix_corner_markers
(
corner_keypoints
,
page_img
.
shape
)
for
problem
in
problems_on_page
:
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
)
corner_keypoints
=
fix_corner_markers
(
corner_keypoints
,
page_img
.
shape
)
# TODO: Assume the minimal x value will be of the top left corner
top_left
=
sorted
(
corner_keypoints
,
key
=
lambda
x
:
x
[
0
])[
0
]
# check if box is filled
if
box_is_filled
(
box
,
page_img
,
corner_keypoints
):
if
box_is_filled
(
box
,
page_img
,
top_left
):
sol
.
feedback
.
text
=
mc_option
.
label
db
.
session
.
commit
()
...
...
@@ -82,10 +84,10 @@ def box_is_filled(box, page_img, corner_keypoints, marker_margin=72/2.54, thresh
# add the actually margin from the scan to corner markers to the coords in inches
dpi
=
guess_dpi
(
page_img
)
coords
[
0
]
=
coords
[
0
]
+
corner_keypoints
[
1
]
[
1
]
/
dpi
coords
[
1
]
=
coords
[
1
]
+
corner_keypoints
[
1
]
[
1
]
/
dpi
coords
[
2
]
=
coords
[
2
]
+
corner_keypoints
[
0
]
[
0
]
/
dpi
coords
[
3
]
=
coords
[
3
]
+
corner_keypoints
[
0
]
[
0
]
/
dpi
coords
[
0
]
=
coords
[
0
]
+
corner_keypoints
[
1
]
/
dpi
coords
[
1
]
=
coords
[
1
]
+
corner_keypoints
[
1
]
/
dpi
coords
[
2
]
=
coords
[
2
]
+
corner_keypoints
[
0
]
/
dpi
coords
[
3
]
=
coords
[
3
]
+
corner_keypoints
[
0
]
/
dpi
# get the box where we think the box is
cut_im
=
get_box
(
page_img
,
coords
,
padding
=
cut_padding
)
...
...
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