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
bb0b131d
Commit
bb0b131d
authored
5 years ago
by
Ruben Young On
Browse files
Options
Downloads
Patches
Plain Diff
test
parent
ce9e1ed3
No related branches found
Branches containing commit
No related tags found
1 merge request
!17
Add pregrading
Pipeline
#17922
failed
5 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
zesje/pregrader.py
+12
-9
12 additions, 9 deletions
zesje/pregrader.py
zesje/scans.py
+16
-16
16 additions, 16 deletions
zesje/scans.py
with
28 additions
and
25 deletions
zesje/pregrader.py
+
12
−
9
View file @
bb0b131d
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
import
cv2
import
cv2
import
numpy
as
np
import
numpy
as
np
from
zesje.database
import
db
,
Solution
,
Problem
from
zesje.database
import
db
,
Solution
,
Problem
,
ProblemWidget
from
zesje.images
import
guess_dpi
,
get_box
,
fix_corner_markers
from
zesje.images
import
guess_dpi
,
get_box
,
fix_corner_markers
...
@@ -26,20 +26,23 @@ def add_feedback_to_solution(page, page_img, corner_keypoints):
...
@@ -26,20 +26,23 @@ def add_feedback_to_solution(page, page_img, corner_keypoints):
page_img: image of the page
page_img: image of the page
barcode: data from the barcode on the page
barcode: data from the barcode on the page
"""
"""
problems_on_page
=
Problem
.
query
.
filter
(
Problem
.
widget
.
page
==
page
).
all
()
widgets
=
ProblemWidget
.
filter
(
ProblemWidget
.
page
==
page
).
all
()
problems_on_page
=
[
widget
.
problem
for
widget
in
widgets
]
for
problem
in
problems_on_page
:
for
problem
in
problems_on_page
:
for
mc_option
in
problem
.
mc_options
:
for
mc_option
in
problem
.
mc_options
:
sol
=
Solution
.
query
.
filter
(
Solution
.
problem_id
==
problem
.
id
).
one_or_none
()
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
)
corner_keypoints
=
fix_corner_markers
(
corner_keypoints
,
page_img
.
shape
)
corner_keypoints
=
fix_corner_markers
(
corner_keypoints
,
page_img
.
shape
)
# check if box is filled
# check if box is filled
if
box_is_filled
(
box
,
page_img
,
corner_keypoints
):
if
box_is_filled
(
box
,
page_img
,
corner_keypoints
):
sol
.
feedback
.
append
(
mc_option
.
feedback
)
sol
.
feedback
.
append
(
mc_option
.
feedback
)
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
):
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.
zesje/scans.py
+
16
−
16
View file @
bb0b131d
...
@@ -77,22 +77,22 @@ def _process_pdf(scan_id, app_config):
...
@@ -77,22 +77,22 @@ def _process_pdf(scan_id, app_config):
total
=
PyPDF2
.
PdfFileReader
(
open
(
pdf_path
,
"
rb
"
)).
getNumPages
()
total
=
PyPDF2
.
PdfFileReader
(
open
(
pdf_path
,
"
rb
"
)).
getNumPages
()
failures
=
[]
failures
=
[]
try
:
#
try:
for
image
,
page
in
extract_images
(
pdf_path
):
for
image
,
page
in
extract_images
(
pdf_path
):
report_progress
(
f
'
Processing page
{
page
}
/
{
total
}
'
)
report_progress
(
f
'
Processing page
{
page
}
/
{
total
}
'
)
try
:
#
try:
success
,
description
=
process_page
(
success
,
description
=
process_page
(
image
,
exam_config
,
output_directory
image
,
exam_config
,
output_directory
)
)
if
not
success
:
if
not
success
:
print
(
description
)
print
(
description
)
failures
.
append
(
page
)
failures
.
append
(
page
)
except
Exception
as
e
:
#
except Exception as e:
report_error
(
f
'
Error processing page
{
page
}
:
{
e
}
'
)
#
report_error(f'Error processing page {
e.__cause__
}')
return
return
except
Exception
as
e
:
#
except Exception as e:
report_error
(
f
"
Failed to read pdf:
{
e
}
"
)
#
report_error(f"Failed to read pdf: {e}")
raise
#
raise
if
failures
:
if
failures
:
processed
=
total
-
len
(
failures
)
processed
=
total
-
len
(
failures
)
...
...
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