Guest User

Untitled

a guest
Sep 5th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. async def get_message():
  2.     future = asyncio.Future()
  3.     order = order_sock.recv_string()
  4.     future.set_result(order)
  5.     asyncio.wait(0.1)
  6.     if future.done():
  7.         print(future.result())
  8.     return future
  9.  
  10. async def send_frame():
  11.     grabbed, frame = camera.read()
  12.     frame = cv2.resize(frame, (640, 480))
  13.     encoded, buffer = cv2.imencode('.jpg', frame)
  14.     jpg_as_text = base64.b64encode(buffer)
  15.     frame_sock.send(jpg_as_text)
  16.     await asyncio.sleep(0.01)
  17.  
  18.  
  19. async def stream():
  20.     while True:
  21.         await asyncio.gather( get_message() ,send_frame() )
Advertisement
Add Comment
Please, Sign In to add comment