Initial Commit master origin/HEAD origin/master
authorMichael Reeves <michaelreeves808@gmail.com>
Sat, 1 Sep 2018 01:09:38 +0000 (15:09 -1000)
committerMichael Reeves <michaelreeves808@gmail.com>
Sat, 1 Sep 2018 01:09:38 +0000 (15:09 -1000)
bg.png [new file with mode: 0644]
main.py [new file with mode: 0644]
opencv-3.1.0.exe [new file with mode: 0644]
opencv_python-3.4.2+contrib-cp37-cp37m-win32.whl [new file with mode: 0644]

diff --git a/bg.png b/bg.png
new file mode 100644 (file)
index 0000000..7297df0
Binary files /dev/null and b/bg.png differ
diff --git a/main.py b/main.py
new file mode 100644 (file)
index 0000000..03b5540
--- /dev/null
+++ b/main.py
@@ -0,0 +1,66 @@
+import numpy as np
+from PIL import ImageGrab, Image
+import cv2
+import pytesseract
+import math
+import serial
+
+class Process:
+    def __init__(self):
+        self.currentHealth = 100
+        self.ocrErr = False
+
+    def processImg(self, greyImg):
+        self.currentHealth
+        txt = pytesseract.image_to_string(greyImg)
+        print(txt)
+        if txt == '' or txt == '|1oo':
+            return True
+        try:        
+            health = int(txt)
+            self.ocrErr = False
+        except:
+            health = self.currentHealth
+            if not self.ocrErr:
+                health = self.currentHealth - 1
+                self.ocrErr = True
+
+        if health < self.currentHealth:
+            self.currentHealth = health
+            return True
+        return False
+
+def getPort():
+    ard = serial.Serial()
+    ard.port = 'COM6'
+    ard.baudrate = 9600
+    ard.timeout = 1
+    ard.setDTR(False)
+    ard.setRTS(False)
+    ard.open()
+    return ard
+
+def main():
+    ard = getPort()
+    process = Process()
+    while(True):
+        x = 760
+        y = 968
+
+        offx = 50
+        offy = 22
+        img = ImageGrab.grab(bbox=(x, y, x + offx, y + offy)).convert('L')
+        
+        img = np.array(img)
+        cv2.imshow('window', img)
+        
+        ard.write('1'.encode() if process.processImg(img) else '0'.encode())
+
+        if cv2.waitKey(25) & 0xFF == ord('q'):  
+            cv2.destroyAllWindows()
+            break
+    ard.close()
+
+if __name__ == '__main__':
+    main()
+
diff --git a/opencv-3.1.0.exe b/opencv-3.1.0.exe
new file mode 100644 (file)
index 0000000..fb03166
Binary files /dev/null and b/opencv-3.1.0.exe differ
diff --git a/opencv_python-3.4.2+contrib-cp37-cp37m-win32.whl b/opencv_python-3.4.2+contrib-cp37-cp37m-win32.whl
new file mode 100644 (file)
index 0000000..4d39be3
Binary files /dev/null and b/opencv_python-3.4.2+contrib-cp37-cp37m-win32.whl differ