main.py 609 B

12345678910111213141516171819202122232425262728
  1. import cv2
  2. import numpy as np
  3. import zmq
  4. from recognizer import recognize
  5. def euclidian(x1, y1, x2, y2):
  6. return ((x1 - x2)**2 + (y1 - y2)**2)**0.5
  7. cv2.namedWindow("Image", cv2.WINDOW_GUI_NORMAL)
  8. cv2.namedWindow("Image2", cv2.WINDOW_GUI_NORMAL)
  9. context = zmq.Context()
  10. socket = context.socket(zmq.SUB)
  11. socket.setsockopt(zmq.SUBSCRIBE, b"")
  12. port = 5055
  13. socket.connect(f"tcp://192.168.0.113:{port}")
  14. n = 0
  15. while True:
  16. bts = socket.recv()
  17. n += 1
  18. arr = np.frombuffer(bts, np.uint8)
  19. imagege = cv2.imdecode(arr, cv2.IMREAD_COLOR)
  20. recognize(imagege, n, True)
  21. cv2.destroyAllWindows()