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

[Feature] made a classifier based on information retrieved from QR on the omr sheets #116

Merged
merged 60 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
eeee562
Update template.py
rudrapsc Jan 2, 2023
497d223
Update core.py
rudrapsc Jan 2, 2023
4aa24e5
Update builtins.py
rudrapsc Jan 2, 2023
d6cf1d9
Merge branch 'master' into patch-3
rudrapsc Jan 2, 2023
13739ef
Add files via upload
rudrapsc Jan 3, 2023
5ef74f5
Update builtins.py
rudrapsc Jan 3, 2023
d1e4a2b
Update template.py
rudrapsc Jan 5, 2023
cdbb6e1
Update core.py
rudrapsc Jan 5, 2023
44c68d1
Update ReadBarcode.py
rudrapsc Jan 5, 2023
0cce13e
Create sample9
rudrapsc Jan 5, 2023
8fc23b9
Update template.py
rudrapsc Jan 5, 2023
188694b
Delete sample9
rudrapsc Jan 5, 2023
ce45d8e
Create template.json
rudrapsc Jan 5, 2023
6082d9a
Add files via upload
rudrapsc Jan 5, 2023
071d803
Create 12345.json
rudrapsc Jan 5, 2023
6cfe30b
Add files via upload
rudrapsc Jan 5, 2023
abbcacd
Update ReadBarcode.py
rudrapsc Jan 6, 2023
1785409
Update core.py
rudrapsc Jan 6, 2023
c38cca7
Update CropPage.py
rudrapsc Jan 6, 2023
3d7ad4e
Update schema.json
rudrapsc Jan 6, 2023
baeef1e
Update template.py
rudrapsc Jan 6, 2023
275bc0d
Delete template.json
rudrapsc Jan 6, 2023
4d85fb5
Add files via upload
rudrapsc Jan 6, 2023
6893c1b
Delete 12345.json
rudrapsc Jan 6, 2023
54ba9eb
Delete default.json
rudrapsc Jan 6, 2023
bc32959
Create default.json
rudrapsc Jan 6, 2023
f8448bd
Add files via upload
rudrapsc Jan 6, 2023
66170d1
fix: add missing argument after master pull
Udayraj123 Jan 6, 2023
cbe3f02
Update core.py
rudrapsc Jan 8, 2023
c32277a
Update CropPage.py
rudrapsc Jan 8, 2023
03a3633
Update constants.py
rudrapsc Jan 8, 2023
d6b26f9
Update ReadBarcode.py
rudrapsc Jan 8, 2023
b59531b
Update template.py
rudrapsc Jan 8, 2023
7c02834
Update template.py
rudrapsc Jan 8, 2023
2ec0ff9
Add files via upload
rudrapsc Jan 8, 2023
641472a
Update TemplateByBarcode.py
rudrapsc Jan 8, 2023
3a2958d
Update core.py
rudrapsc Jan 8, 2023
9991e96
Merge branch 'master' into patch-3
rudrapsc Jan 8, 2023
a4f0cf0
Update ReadBarcode.py
rudrapsc Jan 14, 2023
8efaed9
Update TemplateByBarcode.py
rudrapsc Jan 14, 2023
0feae00
Update core.py
rudrapsc Jan 14, 2023
335fc18
Update TemplateByBarcode.py
rudrapsc Jan 16, 2023
92317d8
Update schema.json
rudrapsc Jan 16, 2023
208c896
Update core.py
rudrapsc Jan 16, 2023
35ef07b
Update CropPage.py
rudrapsc Jan 16, 2023
53abb17
Update template.py
rudrapsc Jan 16, 2023
2377971
Update ReadBarcode.py
rudrapsc Jan 16, 2023
535c7e6
Create template.json
rudrapsc Jan 16, 2023
74acd4c
Add files via upload
rudrapsc Jan 16, 2023
0d2b87d
Create subsample1-Template.json
rudrapsc Jan 16, 2023
deafea5
Delete samples/sample9 directory
rudrapsc Jan 16, 2023
e760e88
Update CropPage.py
rudrapsc Jan 16, 2023
eb02d82
Update schema.json
rudrapsc Jan 16, 2023
8e08668
Update ReadBarcode.py
rudrapsc Jan 16, 2023
02c64c2
Update TemplateByBarcode.py
rudrapsc Jan 16, 2023
2637479
Create subsample1-template.json
rudrapsc Jan 16, 2023
b4aee47
Delete subsample1-Template.json
rudrapsc Jan 16, 2023
efc058b
Update CropPage.py
rudrapsc Jan 16, 2023
7f2808c
Add files via upload
rudrapsc Jan 16, 2023
2e32745
Add files via upload
rudrapsc Jan 16, 2023
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
164 changes: 164 additions & 0 deletions samples/sample7/configs/subsample1-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
{
"Globals": {
"window_width": 2480,
"window_height": 3508,
"display_width": 2480,
"display_height": 3508
},
"dimensions": [
2480,
3508
],
"bubbleDimensions": [
42,
42
],
"preProcessors": [
{
"name": "Levels",
"options": {
"low": 0.70,
"high": 0.8
}
},
{
"name": "MedianBlur",
"options": {
"kSize": 7
}
}
],
"concatenations": {
"Roll": [
"stu",
"roll0",
"roll1",
"roll2",
"roll3",
"roll4",
"roll5",
"roll6",
"check"
]
},
"singles": [],
"qBlocks": {
"Check1": {
"orig": [
2025,
1280
],
"gaps": [
50,
50
],
"bigGaps": [
20,
20
],
"qNos": [
[
[
"check"
]
]
],
"vals": [
"A",
"B",
"E",
"H",
"J",
"L",
"M"
],
"orient": "V"
},
"Check2": {
"orig": [
2083,
1280
],
"gaps": [
50,
50
],
"bigGaps": [
20,
20
],
"qNos": [
[
[
"check"
]
]
],
"vals": [
"N",
"R",
"U",
"W",
"X",
"Y"
],
"orient": "V"
},
"Stu": {
"orig": [
1636,
1280
],
"gaps": [
50,
50
],
"bigGaps": [
20,
20
],
"qNos": [
[
[
"stu"
]
]
],
"vals": [
"U",
"A",
"HT",
"GT"
],
"orient": "V"
},
"Roll": {
"qType": "QTYPE_ROLL",
"orig": [
1680,
1280
],
"bigGaps": [
115,
11
],
"gaps": [
50.5,
50.5
],
"qNos": [
[
[
"roll0",
"roll1",
"roll2",
"roll3",
"roll4",
"roll5",
"roll6"
]
]
]
}
}
}
Binary file added samples/sample7/sample1.jpg
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/sample7/sample2.jpg
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/sample7/sample3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions samples/sample7/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"Globals": {
"window_width": 2480,
"window_height": 3508,
"display_width": 2480,
"display_height": 3508
},
"dimensions": [
2480,
3508
],
"bubbleDimensions": [
42,
42
],
"TemplateByBarcode":[
{
"name": "ReadBarcode",
"options": {
"top_left":[90,680],
"top_right":[230,880],
"qr_to_output_directory":{
"this will contain papercode": "subsample1"
},
"input_sorting":true
}
}
],
"preProcessors": [
],
"concatenations": {
},
"singles": [],
"qBlocks": {
}
}
2 changes: 1 addition & 1 deletion src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

class Paths:
def __init__(self, output_dir):
self.output_dir = output_dir
self.output_dir = str(output_dir)
self.save_marked_dir = f"{self.output_dir}/CheckedOMRs/"
self.results_dir = f"{self.output_dir}/Results/"
self.manual_dir = f"{self.output_dir}/Manual/"
Expand Down
26 changes: 19 additions & 7 deletions src/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
# TODO: use open_config_with_defaults after making a Config class.
from src.config import CONFIG_DEFAULTS as config
from src.logger import logger

# TODO: further break utils down and separate the imports
from src.utils.imgutils import (
ImageUtils,
MainOperations,
draw_template_layout,
setup_dirs,
)

# TODO: further break utils down and separate the imports
from src.utils.TemplateByBarcode import TemplateByBarcode

# Note: dot-imported paths are relative to current directory
from .processors.manager import ProcessorManager
from .template import Template
Expand All @@ -56,6 +57,7 @@ def entry_point(root_dir, curr_dir, args):
def process_dir(root_dir, curr_dir, args, template=None):

# Update local template (in current recursion stack)

local_template_path = curr_dir.joinpath(constants.TEMPLATE_FILENAME)
if os.path.exists(local_template_path):
template = Template(local_template_path, PROCESSOR_MANAGER.processors)
Expand Down Expand Up @@ -108,7 +110,7 @@ def process_dir(root_dir, curr_dir, args, template=None):

setup_dirs(paths)
out = setup_output(paths, template)
process_files(omr_files, template, args_local, out)
process_files(omr_files, template, args_local, out, curr_dir, root_dir)

elif not subdirs:
# Each subdirectory should have images or should be non-leaf
Expand Down Expand Up @@ -192,6 +194,7 @@ def setup_output(paths, template):
list(template.concatenations.keys()) + template.singles,
key=lambda x: int(x[1:]) if ord(x[1]) in range(48, 58) else 0,
)

ns.empty_resp = [""] * len(ns.resp_cols)
ns.sheetCols = ["file_id", "input_path", "output_path", "score"] + ns.resp_cols
ns.OUTPUT_SET = []
Expand Down Expand Up @@ -248,12 +251,15 @@ def preliminary_check():
# show("Confirm : All bubbles are black",final_marked,1,1)




# TODO: take a look at 'out.paths'
def process_files(omr_files, template, args, out):
def process_files(omr_files, template, args, out, curr_dir, root_dir):
start_time = int(time())
files_counter = 0
STATS.files_not_moved = 0

temp_template = template
rudrapsc marked this conversation as resolved.
Show resolved Hide resolved
PROCESSOR_MANAGER = ProcessorManager()
for file_path in omr_files:
files_counter += 1

Expand All @@ -277,6 +283,11 @@ def process_files(omr_files, template, args, out):
config.dimensions.processing_width,
config.dimensions.processing_height,
)
out_1 = out
if template.TemplateByBarcode != []:
template, out = TemplateByBarcode.TemplateBarcode(
in_omr, template, out, file_name, args, PROCESSOR_MANAGER,curr_dir, root_dir
)

# run pre_processors in sequence
for pre_processor in template.pre_processors:
Expand Down Expand Up @@ -320,6 +331,7 @@ def process_files(omr_files, template, args, out):
# concatenate roll nos, set unmarked responses, etc
resp = process_omr(template, response_dict)
logger.info("\nRead Response: \t", resp, "\n")
logger.info(" f ", multi_marked)
if config.outputs.show_image_level >= 2:
MainOperations.show(
"Final Marked Bubbles : " + file_id,
Expand All @@ -340,7 +352,7 @@ def process_files(omr_files, template, args, out):
resp_array.append(resp[k])

out.OUTPUT_SET.append([file_name] + resp_array)

template = temp_template
# TODO: Add roll number validation here
if multi_marked == 0:
STATS.files_not_moved += 1
Expand Down Expand Up @@ -380,7 +392,7 @@ def process_files(omr_files, template, args, out):
# else:
# TODO: Add appropriate record handling here
# pass

out = out_1
print_stats(start_time, files_counter)

# flush after every 20 files for a live view
Expand Down
26 changes: 24 additions & 2 deletions src/defaults/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"title": "Template Validation Schema",
"description": "OMRChecker input image schema",
"type": "object",

"properties": {
"dimensions": {
"description": "The dimensions to which each input image will be resized to before processing",
Expand All @@ -23,6 +24,24 @@
"minItems": 2,
"maxItems": 2
},
"TemplateByBarcode": {
"description": "Custom configuration values to use in evaluating the QRcode",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"enum": [
"ReadBarcode"
],
"type": "string"
},
"options": {
"type": "object"
}
}
}
},
"preProcessors": {
"description": "Custom configuration values to use in the template's directory",
"type": "array",
Expand Down Expand Up @@ -130,7 +149,9 @@
"reference",
"maxFeatures",
"goodMatchPercent",
"2d"
"2d",
"width",
"height"
]
},
"properties": {
Expand Down Expand Up @@ -274,7 +295,8 @@
"type": "object",
"propertyNames": {
"enum": [
"morphKernel"
"morphKernel",
"use_read_barcode"
]
},
"properties": {
Expand Down
Loading