forked from Udayraj123/OMRChecker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
83 lines (70 loc) · 1.58 KB
/
main.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
"""
OMRChecker
Author: Udayraj Deshmukh
Github: https://github.com/Udayraj123
"""
print(f"Loading OMRChecker modules...")
# It takes a few seconds for the imports
import argparse
from pathlib import Path
from src.core import (
entry_point,
)
# construct the argument parse and parse the arguments
argparser = argparse.ArgumentParser()
argparser.add_argument(
"-i",
"--inputDir",
default=["inputs"],
# https://docs.python.org/3/library/argparse.html#nargs
nargs="*",
required=False,
type=str,
dest="input_paths",
help="Specify an input directory.",
)
argparser.add_argument(
"-o",
"--outputDir",
default="outputs",
required=False,
dest="output_dir",
help="Specify an output directory.",
)
# TODO: separate the interactive modes from main code
argparser.add_argument(
"-a",
"--autoAlign",
required=False,
dest="autoAlign",
action="store_true",
help="(experimental) Enables automatic template alignment - \
use if the scans show slight misalignments.",
)
argparser.add_argument(
"-l",
"--setLayout",
required=False,
dest="setLayout",
action="store_true",
help="Set up OMR template layout - modify your json file and \
run again until the template is set.",
)
(
args,
unknown,
) = argparser.parse_known_args()
args = vars(args)
if len(unknown) > 0:
print(
"\nError: Unknown arguments:",
unknown,
)
argparser.print_help()
exit(11)
for root in args["input_paths"]:
entry_point(
Path(root),
Path(root),
args,
)