title: Sending video frames to client
body: <p>I am currently using OpenCV to read video frames.</p>
  
  <p>On the server side I serialize the frame using cPickle.dumps():</p>
  
  <pre><code>flag, frame = cap.read()
  frame = cPickle.dumps(frame)
  client_socket.sendall(frame)
  </code></pre>
  
  <p>On the client side I serialize the frame using cPickle.loads():</p>
  
  <pre><code>data = sock.recv(4000)
  frame = cPickle.loads(data) # ValueError: insecure string pickle
  self.ImageLabel.configure(image=frame) # Want to show the frame in Tkinter
  self.ImageLabel.image = frame
  self.ImageLabel.grid(row=4, columnspan=40)
  </code></pre>
  
  <p>cPickle.loads(data) causes ValueError: insecure string pickle. What am I doing wrong? I want to read the frame on the client side and show it in tkinter window. I have looked up every where for more than 9 hours but couldn't find a solution.</p>
  
  <p>Edit 1:</p>
  
  <p>I also tried this:</p>
  
  <p>server side</p>
  
  <pre><code>flag, frame = cap.read()
  if flag:
      size = sys.getsizeof(frame)
      client_socket.send(str(size))
      client_socket.sendall(cPickle.dumps(frame.tolist()))
  </code></pre>
  
  <p>client side</p>
  
  <pre><code>size = sock.recv(4000)
  data = sock.recv(int(size))
  frame = cPickle.loads(data) # Causes EOFError 
  </code></pre>
  
  <p>Edit 2:
  server side</p>
  
  <pre><code>flag, frame = cap.read()
  if flag:
     frame = cPickle.dumps(frame)
     size = len(frame)
     p = struct.pack("I", size)
     client_socket.send(p)
     client_socket.sendall(frame)
  </code></pre>
  
  <p>client side</p>
  
  <pre><code>sizep = sock.recv(struct.calcsize("I"))
  data_size = struct.unpack("I",sizep)
  print type (data_size) # tuple - has (11026730, )
  data = sock.recv(int(data_size[0]))
  frame = cPickle.loads(data) # ValueError: insecure string pickle
  </code></pre>