Facebook
From Chartreuse Terrapin, 3 Years ago, written in Python.
Embed
Download Paste or View Raw
Hits: 126
  1. import time
  2. import zmq
  3. import numpy as np
  4. import cv2
  5.  
  6. context = zmq.Context()
  7. socket = context.socket(zmq.PUB)
  8. socket.bind('tcp://192.168.1.165:2000')
  9. cap = cv2.VideoCapture(0)
  10. # Allow clients to connect before sending data
  11. time.sleep(0.1)
  12.  
  13. #a = np.random.rand(1024,720,3)
  14. while True:
  15.     ret, frame = cap.read()
  16.     font = cv2.FONT_HERSHEY_SIMPLEX
  17.     img_flip_lr = cv2.flip(frame, 1)
  18.     org = (50, 50)
  19.  
  20.     # fontScale
  21.     fontScale = 1
  22.    
  23.     # Blue color in BGR
  24.     color = (255, 0, 0)
  25.    
  26.     # Line thickness of 2 px
  27.     thickness = 2
  28.     zaman = time.time()
  29.     zaman = str(zaman)
  30.     # Using cv2.putText() method
  31.     img_flip_lr = cv2.putText(img_flip_lr, zaman, org, font,  
  32.                     fontScale, color, thickness, cv2.LINE_AA)
  33.     socket.send_pyobj(img_flip_lr)
  34.     print("gönderdim")
  35.     cv2.imshow('server',img_flip_lr)
  36.    
  37.     if cv2.waitKey(1) & 0xFF == ord('q'):
  38.         break
  39.    
  40.  
  41. cap.release()
  42. cv2.destroyAllWindows()