-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
40 lines (33 loc) · 1.09 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
import cv2
import task
import threading
# Video source
video_src = "rtsp://admin:123456@10.180.249.36:8554/live"
# video_src = 0
if __name__ == "__main__":
# start the buffer thread to get the newest frame
buffer = task.frameBuffer(video_src)
buffer_thread = threading.Thread(target=buffer.stream_on)
buffer_thread.start()
# spin wait until the buffer is ready
while buffer.get_newest_frame() is None:
continue
print("Press q to stop scanning.")
while True:
# _, img = cap.read()
img = buffer.get_newest_frame()
cv2.namedWindow('Camera', flags=cv2.WINDOW_NORMAL | cv2.WINDOW_KEEPRATIO | cv2.WINDOW_GUI_EXPANDED)
cv2.imshow("Camera", img)
scanner = task.answerSheetScanner(img, verbose=False)
try:
scanner.process()
break
except Exception as e:
# print(e)
# print("Failed to process the image.")
if cv2.waitKey(1) & 0xFF == ord('q'):
print("Quit.")
break
continue
buffer.turn_off()
cv2.destroyAllWindows()