-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartATM.py
More file actions
49 lines (39 loc) · 1.43 KB
/
Copy pathstartATM.py
File metadata and controls
49 lines (39 loc) · 1.43 KB
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
import cv2
from bank_scanner import parse_form_image
import time
class ATM:
def __init__(self):
self.camera = cv2.VideoCapture(0)
if not self.camera.isOpened():
raise Exception("Could not open video device")
def start(self):
print("ATM started. Press 'q' to quit.")
try:
while True:
# Capture frame-by-frame
ret, frame = self.camera.read()
if not ret:
print("Failed to grab frame")
break
# Save the frame temporarily
temp_image = "temp_capture.jpg"
cv2.imwrite(temp_image, frame)
# Try to parse the account number
result = parse_form_image(temp_image)
if result:
print(f"Detected account number: {result}")
# Display the frame
cv2.imshow('ATM Camera', frame)
# Break the loop on 'q' key press
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Add a small delay to prevent high CPU usage
time.sleep(0.1)
finally:
self.camera.release()
cv2.destroyAllWindows()
def main():
atm = ATM()
atm.start()
if __name__ == "__main__":
main()