forked from Udayraj123/OMRChecker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
globals.py
140 lines (115 loc) · 4.32 KB
/
globals.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
"""
Designed and Developed by-
Udayraj Deshmukh
https://github.com/Udayraj123
"""
"""
Constants
"""
display_height = int(480)
display_width = int(640)
windowWidth = 1280
windowHeight = 720
saveMarked = 1
saveCropped = 1
showimglvl = 4
saveimglvl = 0
PRELIM_CHECKS = 0
saveImgList = {}
resetpos = [0, 0]
explain = 0
# autorotate=1
BATCH_NO = 1000
NO_MARKER_ERR = 12
MULTI_BUBBLE_WARN = 15
# name of template file
TEMPLATE_FILE = 'template.json'
MARKER_FILE = "omr_marker.jpg"
# For preProcessing
GAMMA_LOW = 0.7
GAMMA_HIGH = 1.25
ERODE_SUB_OFF = 1
# For new ways of determining threshold
MIN_GAP, MIN_STD = 30, 25
MIN_JUMP = 25
# If only not confident, take help of globalTHR
CONFIDENT_JUMP = MIN_JUMP + 15
JUMP_DELTA = 30
# MIN_GAP : worst case gap of black and gray
# Templ alignment parameters
ALIGN_RANGE = range(-5, 6, 1)
# TODO ^THIS SHOULD BE IN LAYOUT FILE AS ITS RELATED TO DIMENSIONS
# ALIGN_RANGE = [-6,-4,-2,-1,0,1,2,4,6]
# max threshold difference for template matching
thresholdVar = 0.41
# TODO: remove unnec variables here-
thresholdCircle = 0.3
marker_rescale_range = (35, 100)
marker_rescale_steps = 10
# Presentation variables
uniform_height = int(1231 / 1.5)
uniform_width = int(1000 / 1.5)
# Original dims are about (3527, 2494)
# Any input images should be resized to this--
uniform_width_hd = int(uniform_width * 1.5)
uniform_height_hd = int(uniform_height * 1.5)
TEXT_SIZE = 0.95
CLR_BLACK = (50, 150, 150)
CLR_WHITE = (250, 250, 250)
CLR_GRAY = (130, 130, 130)
# CLR_DARK_GRAY = (190,190,190)
CLR_DARK_GRAY = (100, 100, 100)
MIN_PAGE_AREA = 80000
# Filepaths
class Paths:
def __init__(self, output):
self.output = output
self.saveMarkedDir = f'{output}/CheckedOMRs/'
self.resultDir = f'{output}/Results/'
self.manualDir = f'{output}/Manual/'
self.errorsDir = f'{self.manualDir}ErrorFiles/'
self.badRollsDir = f'{self.manualDir}BadRollNosFiles/'
self.multiMarkedDir = f'{self.manualDir}MultiMarkedFiles/'
"""
Variables
"""
filesMoved = 0
filesNotMoved = 0
# for positioning image windows
windowX, windowY = 0, 0
# TODO: move to template or similar json
Answers = {
'J': {
'q1': ['B'], 'q2': ['B'], 'q3': ['B'], 'q4': ['C'], 'q5': ['0', '00'], 'q6': ['0', '00'], 'q7': ['4', '04'],
'q8': ['9', '09'], 'q9': ['11', '11'], 'q10': ['C'], 'q11': ['C'], 'q12': ['B'], 'q13': ['C'],
'q14': ['C'], 'q15': ['B'], 'q16': ['C'], 'q17': ['BONUS'], 'q18': ['A'], 'q19': ['C'], 'q20': ['B']},
'H': {
'q1': ['B'], 'q2': ['BONUS'], 'q3': ['A'], 'q4': ['B'], 'q5': ['A'], 'q6': ['B'], 'q7': ['B'],
'q8': ['C'], 'q9': ['4', '04'], 'q10': ['4', '04'], 'q11': ['5', '05'], 'q12': ['1', '01'], 'q13': ['28'],
'q14': ['C'], 'q15': ['B'], 'q16': ['C'], 'q17': ['C'], 'q18': ['C'], 'q19': ['B'], 'q20': ['C']},
'JK': {
'q1': ['B'], 'q2': ['B'], 'q3': ['B'], 'q4': ['C'], 'q5': ['0', '00'], 'q6': ['0', '00'], 'q7': ['4', '04'],
'q8': ['9', '09'], 'q9': ['11', '11'], 'q10': ['C'], 'q11': ['C'], 'q12': ['B'], 'q13': ['C'],
'q14': ['C'], 'q15': ['B'], 'q16': ['C'], 'q17': ['BONUS'], 'q18': ['A'], 'q19': ['C'], 'q20': ['B']},
'HK': {
'q1': ['B'], 'q2': ['BONUS'], 'q3': ['A'], 'q4': ['B'], 'q5': ['B'], 'q6': ['B'], 'q7': ['B'],
'q8': ['C'], 'q9': ['4', '04'], 'q10': ['4', '04'], 'q11': ['5', '05'], 'q12': ['1', '01'], 'q13': ['28'],
'q14': ['C'], 'q15': ['B'], 'q16': ['C'], 'q17': ['C'], 'q18': ['C'], 'q19': ['B'], 'q20': ['C']},
}
# TODO: Make this generalized and move it to samples
Sections = {
'J': {
'Fibo1': {'ques': [1, 2, 3, 4], '+seq': [2, 3, 5, 8], '-seq': [0, 1, 1, 2]},
'Power1': {'ques': [5, 6, 7, 8, 9], '+seq': [1, 2, 4, 8, 16], '-seq': [0, 0, 0, 0, 0]},
'Fibo2': {'ques': [10, 11, 12, 13], '+seq': [2, 3, 5, 8], '-seq': [0, 1, 1, 2]},
'allNone1': {'ques': [14, 15, 16], 'marks': 12},
'Boom1': {'ques': [17, 18, 19, 20], '+seq': [3, 3, 3, 3], '-seq': [1, 1, 1, 1]},
},
'H': {
'Boom1': {'ques': [1, 2, 3, 4], '+seq': [3, 3, 3, 3], '-seq': [1, 1, 1, 1]},
'Fibo1': {'ques': [5, 6, 7, 8], '+seq': [2, 3, 5, 8], '-seq': [0, 1, 1, 2]},
'Power1': {'ques': [9, 10, 11, 12, 13], '+seq': [1, 2, 4, 8, 16], '-seq': [0, 0, 0, 0, 0]},
'allNone1': {'ques': [14, 15, 16], 'marks': 12},
'Boom2': {'ques': [17, 18, 19, 20], '+seq': [3, 3, 3, 3], '-seq': [1, 1, 1, 1]},
},
}