Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Evaluation; Multi weighted bugfixes; Colored Outputs base #174

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a459da5
fix: remove whitespaces when reading csv
Udayraj123 Feb 18, 2024
d694307
fix: debugging help
Udayraj123 Feb 18, 2024
5065518
fix: wip add white padding for morphology
Udayraj123 Feb 18, 2024
d26d41f
fix: debugging help
Udayraj123 Feb 26, 2024
bb1865d
feat: support for answers_summary_string; add Verdict DotMap
Udayraj123 Feb 26, 2024
d2d21e4
fix: conflict issues
Udayraj123 Mar 23, 2024
df58b3d
feat: support colored images wip; refactor processing_width -> proces…
Udayraj123 Mar 23, 2024
559c5ba
feat: support colored images; refactor processing_width -> processing…
Udayraj123 Mar 23, 2024
583e46b
feat: defaults for evaluation; support answers_summary_format_string;…
Udayraj123 Mar 24, 2024
0a42d2d
feat: compress img
Udayraj123 Mar 24, 2024
ae3e991
feat: add pre-commit-images
Udayraj123 Mar 24, 2024
6bb668e
feat: add pre-commit-images
Udayraj123 Mar 24, 2024
62a0764
fix: conflict issues
Udayraj123 Mar 24, 2024
79a90f3
fix: rename samples wip
Udayraj123 Mar 24, 2024
30695ed
fix: wip position support for draw_score, draw_answer_summary
Udayraj123 Mar 24, 2024
c7c6251
Updated output_configuration
palash018 Mar 26, 2024
ad91a4a
fix: wip rearrange samples; add docs for Crop on Timelines; add sampl…
Udayraj123 Mar 28, 2024
238582b
feat: add two-dots-one-line sample
Udayraj123 Mar 28, 2024
62af617
feat: add four-dots sample
Udayraj123 Mar 28, 2024
d336044
fix: wip rearrange samples; rename tests
Udayraj123 Mar 28, 2024
8b7bc75
fix: wip rearrange samples; remove AutoShiftFieldBlocks
Udayraj123 Mar 30, 2024
b7a5509
Removed comments
palash018 Mar 30, 2024
b61fa0a
fix: wip rearrange samples; add CropOnControlPoints and migrate inter…
Udayraj123 Mar 30, 2024
c562b34
fix: wip rearrange pre-processors
Udayraj123 Mar 30, 2024
e2be45e
fix: conflicts and sample
Udayraj123 Mar 30, 2024
961063d
fix: add contributor palash018
Udayraj123 Mar 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ outputs/*

# Misc
**/.DS_Store
**/__ignore__
**/__pycache__
venv/
OMRChecker.wiki/
23 changes: 19 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
exclude: "__snapshots__/.*$"
default_install_hook_types: [pre-commit, pre-push]
repos:
# Run image compressor before the large files check
- repo: https://github.com/boidolr/pre-commit-images
rev: v1.5.2
hooks:
- id: optimize-png
- id: optimize-jpg
args: ["--quality","90"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
stages: [commit]
- id: check-added-large-files
args: ['--maxkb=300']
args: ["--maxkb=300"]
fail_fast: false
stages: [commit]
- id: pretty-format-json
args: ['--autofix', '--no-sort-keys']
args: ["--autofix", "--no-sort-keys"]
- id: end-of-file-fixer
exclude_types: ["csv", "json"]
stages: [commit]
Expand All @@ -34,14 +42,21 @@ repos:
hooks:
- id: flake8
args:
- "--ignore=E501,W503,E203,E741,F541" # Line too long, Line break occurred before a binary operator, Whitespace before ':'
- "--ignore=E203,E501,E741,E731,F541,W503"
# https://www.flake8rules.com/
# E203: Whitespace before ':'
# E501: Line too long
# E731: do not assign a lambda expression, use a def
# E741: Do not use variables named 'I', 'O', or 'l'
# F541: f-string without any placeholders
# W503: Line break occurred before a binary operator
fail_fast: true
stages: [commit]
- repo: local
hooks:
- id: pytest-on-commit
name: Running single sample test
entry: python3 -m pytest -rfpsxEX --disable-warnings --verbose -k sample1
entry: python3 -m pytest -rfpsxEX --disable-warnings --verbose -k test_run_omr_marker_mobile
language: system
pass_filenames: false
always_run: true
Expand Down
1 change: 1 addition & 0 deletions Contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
- [aayushibansal2001](https://github.com/aayushibansal2001)
- [ShamanthVallem](https://github.com/ShamanthVallem)
- [rudrapsc](https://github.com/rudrapsc)
- [palash018](https://github.com/palash018)
Binary file added samples/1-mobile-camera/MobileCamera/sheet1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions samples/1-mobile-camera/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"outputs": {
"show_image_level": 0,
"show_colored_outputs": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"fieldBlocks": {
"Medium": {
"bubblesGap": 41,
"fieldType": "CUSTOM",
"bubbleValues": [
"E",
"H"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
This sample demonstrates multiple things, namely -
- Running OMRChecker on images scanned using popular document scanning apps
- Using a common template.json file for sub-folders (e.g. multiple scan batches)
- Using evaluation.json file with custom marking (without streak-based marking)
- Using evaluation on custom labels
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
},
"fieldBlocks": {
"Medium": {
"fieldType": "CUSTOM",
"bubbleValues": [
"E",
"H"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"dimensions": {
"display_width": 1189,
"display_height": 1682
"display_image_shape": [
1682,
1189
]
},
"threshold_params": {
"thresholding": {
"MIN_JUMP": 30
},
"outputs": {
Expand Down
76 changes: 76 additions & 0 deletions samples/3-answer-key/bonus-marking/evaluation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"source_type": "custom",
"options": {
"questions_in_order": [
"q1..11"
],
"answers_in_order": [
"B",
"D",
"C",
"B",
"D",
"C",
[
"B",
"C",
"BC"
],
"A",
"C",
"D",
"C"
],
"should_explain_scoring": true
},
"outputs_configuration": {
"draw_score": {
"enabled": true,
"position": [
600,
650
],
"size": 1.5
},
"draw_answers_summary": {
"enabled": true,
"position": [
300,
550
],
"size": 1.0
},
"verdict_colors": {
"correct": "#00ff00",
"incorrect": "#ff0000",
"unmarked": "#0000ff"
}
},
"marking_schemes": {
"DEFAULT": {
"correct": "3",
"incorrect": "-1",
"unmarked": "0"
},
"BONUS_MARKS_ON_ATTEMPT": {
"marking": {
"correct": "3",
"incorrect": "3",
"unmarked": "0"
},
"questions": [
"q7"
]
},
"BONUS_MARKS_FOR_ALL": {
"marking": {
"correct": "3",
"incorrect": "3",
"unmarked": "3"
},
"questions": [
"q8"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"pageDimensions": [
1189,
1682
1200,
1500
],
"bubbleDimensions": [
30,
Expand Down Expand Up @@ -32,14 +32,14 @@
"MCQBlock1": {
"fieldType": "QTYPE_MCQ4",
"origin": [
134,
684
138,
605
],
"fieldLabels": [
"q1..11"
],
"bubblesGap": 79,
"labelsGap": 62
"labelsGap": 55
}
}
}
Binary file added samples/3-answer-key/using-csv/adrian_omr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/3-answer-key/using-image/answer_key.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions samples/3-answer-key/using-image/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"dimensions": {
"display_image_shape": [
2400,
1800
],
"processing_image_shape": [
2400,
1800
]
},
"outputs": {
"show_image_level": 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"fieldLabels": [
"bookletNo"
],
"fieldType": "CUSTOM",
"bubbleValues": [
"A",
"B",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
"q1..5"
],
"answers_in_order": [
"C",
[
[
"A",
3
],
[
"C",
-2
]
],
"E",
[
"A",
Expand All @@ -30,6 +39,16 @@
"correct": "3",
"incorrect": "-1",
"unmarked": "0"
},
"CUSTOM_NEGATIVE_MARKING": {
"questions": [
"q5"
],
"marking": {
"correct": "3",
"incorrect": "-2",
"unmarked": "0"
}
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed samples/answer-key/using-csv/adrian_omr.png
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions samples/community/Sandeep-1507/config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"dimensions": {
"display_height": 1000,
"display_width": 1300,
"processing_height": 820,
"processing_width": 666
"display_image_shape": [
1000,
1300
],
"processing_image_shape": [
820,
666
]
},
"outputs": {
"save_detections": true,
Expand Down
Binary file removed samples/community/Sandeep-1507/omr-1.png
Binary file not shown.
Binary file removed samples/community/Sandeep-1507/omr-2.png
Binary file not shown.
Binary file removed samples/community/Sandeep-1507/omr-3.png
Binary file not shown.
Binary file removed samples/community/UPSC-mock/answer_key.jpg
Binary file not shown.
11 changes: 0 additions & 11 deletions samples/community/UPSC-mock/config.json

This file was deleted.

Binary file removed samples/community/UPSC-mock/scan-angles/angle-1.jpg
Binary file not shown.
Binary file removed samples/community/UPSC-mock/scan-angles/angle-2.jpg
Diff not rendered.
Binary file removed samples/community/UPSC-mock/scan-angles/angle-3.jpg
Diff not rendered.
12 changes: 8 additions & 4 deletions samples/community/UmarFarootAPS/config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"dimensions": {
"display_height": 960,
"display_width": 1280,
"processing_height": 1640,
"processing_width": 1332
"display_image_shape": [
960,
1280
],
"processing_image_shape": [
1640,
1332
]
},
"outputs": {
"show_image_level": 0
Expand Down
3 changes: 2 additions & 1 deletion samples/community/ibrahimkilic/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
"emptyValue": "no",
"fieldBlocks": {
"YesNoBlock1": {
"direction": "horizontal",
"fieldType": "CUSTOM",
"bubbleValues": [
"yes"
],
"direction": "horizontal",
"origin": [
15,
55
Expand Down
31 changes: 31 additions & 0 deletions samples/experimental/1-timelines-and-dots/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## Sample OMRs
# What is a Dot (index point)?
We can use any blob-like unique shape on the OMR sheet to be used as the four index points aka Dots.
These 4 points provided at the 4 corners of the OMR sheet are the most important components of an OMR sheet. The accuracy of evaluation depends on the clarity of these 4 points in the scanned OMR sheet image.

# What is a Timeline on an OMR sheet?

In the old pattern, machine read sheets, were additional black marks placed at equal increments running throughout the length of the sheet on either side or on both sides. This strip of black marks is called a timeline which helps the OMR machine to identify the next row of bubbles. ([source](https://www.addmengroup.com/downloads/Addmen-OMR-Sheet-Design-Guide.pdf))

OMR software can use the timeline to properly locate the bubbles. So any changes in the timeline markers can generate wrong result. It is usually not larger than the size of bubbles

<!-- TODO: image of a timeline -->

# When should I use it?

- If your OMR sheet has this timeline and if adding a custom marker(in four corner points) is not feasible, you can try evaluating your OMR sheet using this method.
- Since the preprocessor converts the dashed line into a filled rectangular blob and uses that for detection, you can use this preprocessor on any rectangular thick lines or thick dots that can be converted to distinguishable blobs.

# How to use?
We have provided support for 4 configurations: "ONE_LINE_TWO_DOTS", "TWO_DOTS_ONE_LINE", "TWO_LINES", "FOUR_DOTS".
Depending on the configuration of your OMR sheet, choose the one that is applicable.

Open the samples in this folder to know how to configure each type in detail.

Also, for further tuning - we support 5 configurations for selecting the points out of the thick blobs: "CENTERS", "INNER_WIDTHS", "INNER_HEIGHTS", "INNER_CORNERS", "OUTER_CORNERS"

### Drawbacks and Improvements
Currently OMRChecker requires the Dots and Lines to "stand out" from other marks in the sheet. If there's any noise nearby the marker including the print itself, the detection would fail.
<!-- TODO: insert obstructed OMR -->

Track improvements in this functionality [here](https://github.com/users/Udayraj123/projects/2?pane=issue&itemId=57863176).
15 changes: 15 additions & 0 deletions samples/experimental/1-timelines-and-dots/four-dots/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"dimensions": {
"display_image_shape": [
1800,
2400
],
"processing_image_shape": [
1280,
906
]
},
"outputs": {
"show_image_level": 0
}
}
Loading