title: Send JSON with image as bytes using WebSocket
body: <p>I want to send and receive image from cv2.Videocapture using WebSocket.</p>
  
  <p>It could get json, but it couldn't decoded.</p>
  
  <p>We need result that can be opened using cv2.imshow().</p>
  
  <p>Somebody help me...</p>
  
  <p><strong>This is Client</strong></p>
  
  <pre><code>ret, image_np = cap.read()
          IMAGE_SHAPE = image_np.shape
          encoded_image = base64.b64encode(image_np)
          print(type(encoded_image))
          payload = {
              'from': 'rasp',
              'image': str(encoded_image),
              'shape': IMAGE_SHAPE,
          }
  
          data = json.dumps(payload)
  
          try:
              # Send encoded image data.
              await websocket.send(data)
  
              # receive server message
              received_data = await websocket.recv()
              print('&lt; {}'.format(received_data))
  
              # image = base64.b64decode(received_data)
              # np_image = np.fromstring(image, dtype=np.uint8)
              # source = np_image.reshape(IMAGE_SHAPE)
              return websocket
          except Exception:
              print('WebSocket send or receive error.')
              exit(1)
  </code></pre>
  
  <p><strong>This is Server</strong></p>
  
  <pre><code>async def server_on(websocket, path):
  payload = {
      'from': 'image-server',
      # 'result': {
      #     # Default is null.
      #     'isPerson': &lt;bool&gt;,
      #     'centerPoint': &lt;(x, y)&gt;,
      # },
  }
  
  data = json.dumps(payload)
  
  try:
      payload = await websocket.recv()
      receive_data = json.loads(payload)
      # At this line doesnt work... 
      decoded_image = base64.b64decode(receive_data['image'])
      image_np = np.fromstring(decoded_image, dtype=np.uint8)
      source = image_np.reshape(receive_data['shape'])
  
  
      await websocket.send(data)
  except Exception:
      websocket.close()
      return
  </code></pre>