From 9dcff4bedfb73d0c41112ee7198ae6cb4d64b02e Mon Sep 17 00:00:00 2001
From: zhaoliang <zhz03@g.ucla.edu>
Date: Thu, 28 Oct 2021 03:54:35 -0700
Subject: [PATCH] upload new web code

---
 .../PyTorch_with_ESPCAM/imageTread_web.py     | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 Code/Ball_Detection/PyTorch_with_ESPCAM/imageTread_web.py

diff --git a/Code/Ball_Detection/PyTorch_with_ESPCAM/imageTread_web.py b/Code/Ball_Detection/PyTorch_with_ESPCAM/imageTread_web.py
new file mode 100644
index 0000000..82bdc6b
--- /dev/null
+++ b/Code/Ball_Detection/PyTorch_with_ESPCAM/imageTread_web.py
@@ -0,0 +1,23 @@
+import urllib.request
+import cv2
+import numpy as np
+
+if __name__ == '__main__':
+
+    frame = None
+    key = None
+    url = 'http://192.168.1.117/capture?'
+    # url = 'http://192.168.1.117:81/stream'
+    print('Start')
+    while True:
+        imgResponse = urllib.request.urlopen(url)
+        imgNp = np.array(bytearray(imgResponse.read()),dtype=np.uint8)
+        frame = cv2.imdecode(imgNp,-1)
+        cv2.imshow('Window',frame)
+        h, w, _ = frame.shape
+        print("with:{},high:{}".format(w, h))
+        key = cv2.waitKey(5)
+        if key == ord('q'):
+            break
+
+    cv2.destroyAllWindows()
-- 
GitLab