This repository has been archived by the owner on May 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
59 lines (45 loc) · 1.84 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
# AIMER: Artificial Intelligence Mark Evaluator & Recognizer
# Copyright (C) 2022 Fereydoun Memarzanjany
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import logging
import time
from utils import camera_driver, scanner, grader
import cv2 as cv
import numpy as np
# This sets the root logger to write to stdout. Also, by default the
# logger is set to print (only) WARNINGs, we want INFOs to get printed as well.
logging.basicConfig(encoding="utf-8", level=logging.NOTSET)
cap = camera_driver.init_camera()
def main():
cv.namedWindow("webcam")
cv.namedWindow("graded")
img = None
scanned = None
#image = cv.imread("test.png", cv.IMREAD_GRAYSCALE)
while True:
_ret, img = cap.read()
img, scanned_img = scanner.scan(img)
cv.imshow("webscam", img)
score, graded_img = grader.grade(scanned_img)
cv.imshow("graded", graded_img)
if (cv.waitKey(33) == ord('s')):
break
print("The final grade was: " + str(score) + "%")
cv.destroyAllWindows()
# Main harness function for driving the code.
if (__name__ == "__main__"): # The module is being run directly
main()
else: # The module is being imported into another one
pass