if self.frame is None or self.frame.size == 0: continue else: self.frame = cv2.resize(self.frame, dsize=(160, 120)) _, buf = cv2.imencode('.jpg', self.frame) jpg_as_text = base64.b64encode(buf) self.client.publish("Tello-Video/jpg-image", jpg_as_text) def on_message(client, userdata, msg): global frame img = base64.b64decode(msg.payload) # converting into numpy array from buffer npimg = np.frombuffer(img, dtype=np.uint8) tmp_frame = cv2.imdecode(npimg, 3) # Convert RBG to BGR for opencv image frame = cv2.cvtColor(tmp_frame, cv2.COLOR_RGB2BGR)