I have the following code sending frames from the client to the server. I am unable to receive complete frames from the client to the server. Sometimes I receive on the server-side 1888 frames sometimes 2000 frames, the total frames are 2522.
Client.py
context = zmq.Context()
footage_socket = context.socket(zmq.PUB)
footage_socket.connect('tcp://localhost:9999')
videoFile = "E:/sample.mp4"
camera = cv2.VideoCapture(videoFile)
count = 0
while True:
grabbed, frame = camera.read()
count += 1
print(count)
try:
frame = cv2.resize( frame, (224, 224) )
except cv2.error:
break
encoded, buffer = cv2.imencode('.jpg', frame)
jpg_as_text = base64.b64encode(buffer)
footage_socket.send(jpg_as_text)
Server.py
context = zmq.Context()
footage_socket = context.socket(zmq.SUB)
footage_socket.bind('tcp://*:9999')
footage_socket.setsockopt_string(zmq.SUBSCRIBE, np.unicode(''))
count = 0
while True:
frame = footage_socket.recv_string()
count += 1
print(count)
Thanks, help is highly appreciated.