Python MQTT Publish JSONified Numpy Array












0















I am currently implementing a MQTT protocol to be used between two raspberry pis. The first is a Pi 0 and will have a pi camera connected to it. It will be converting each captured frame to a numpy array and then publish it to the master Pi which will then convert the numpy array to an image using PIL. I am doing it this way since I want the main image processing operations to be performed on the master Pi.



My problem is that no messages are being received by the master Pi. I have preformed debugging and everything is working fine on the servant script. But for some reason nothing is received by the master Pi.



Here are both scripts:



servant.py:



import paho.mqtt.client as mqtt
import time
import cv2
import numpy
import json

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

mqttc = mqtt.Client()
mqttc.connect(MQTT_SERVER, 1883, 60)

cap = cv2.VideoCapture(0)

while True:
ret, frame = cap.read()
frame_list = frame.tolist()
MQTT_MESSAGE = json.dumps(frame_list)
mqttc.publish(MQTT_PATH, MQTT_MESSAGE)
time.sleep(1)


master.py:



import paho.mqtt.client as mqtt
import numpy as np
import json
import PIL

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

def on_connect(client, userdata, flags, rc):
print("connected with result code " + str(rc))
client.subscribe(MQTT_PATH)

def on_message(client, userdata, msg):
data = json.loads(msg.payload)
array = np.array(data)
img = PIL.Image.fromarray(array)
cv2.imshow('image', img)
cv2.waitKey()

client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect(MQTT_SERVER, 1883, 60)

client.loop_forever()









share|improve this question

























  • You need to explain what you have tried, just saying "I have performed debugging" doesn't help

    – hardillb
    Nov 19 '18 at 10:21











  • Also you are blocking in the on_message by calling cv2.waitKey() this means the whole subscriber will lock up while processing the first message until you press a key. You should not block messaging handling.

    – hardillb
    Nov 19 '18 at 10:25






  • 1





    Don't need to call mqttc.loop_start() in your client (or periodically call loop from within your for loop)?

    – larsks
    Nov 19 '18 at 12:40











  • @hardillb sorry i didnt specify the exact debugging techniques but i think it is redundant nonetheless because the servant script is working perfectly fine. But, to answer your question i did a few logging statements on the servant.py and the data is being processed properly and is jsonified. I also made a dummy numpy array and that actually went through and was published. But for some reason the moment i use opencv it stops working. Once again even with the opencv on the servant.py everything works fine, publishing is the problem.

    – Noor Sabbagh
    Nov 19 '18 at 13:05











  • @hardillb as for your suggestion I removed that line but there was still nothing showing up. Don't even think that is the problem, because i quickly debugged it using a print statement, first line in the on_message method, and the msg.payload's value is not printed. Which means that somewhere between the publish and the on_message something is going wrong.

    – Noor Sabbagh
    Nov 19 '18 at 13:07
















0















I am currently implementing a MQTT protocol to be used between two raspberry pis. The first is a Pi 0 and will have a pi camera connected to it. It will be converting each captured frame to a numpy array and then publish it to the master Pi which will then convert the numpy array to an image using PIL. I am doing it this way since I want the main image processing operations to be performed on the master Pi.



My problem is that no messages are being received by the master Pi. I have preformed debugging and everything is working fine on the servant script. But for some reason nothing is received by the master Pi.



Here are both scripts:



servant.py:



import paho.mqtt.client as mqtt
import time
import cv2
import numpy
import json

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

mqttc = mqtt.Client()
mqttc.connect(MQTT_SERVER, 1883, 60)

cap = cv2.VideoCapture(0)

while True:
ret, frame = cap.read()
frame_list = frame.tolist()
MQTT_MESSAGE = json.dumps(frame_list)
mqttc.publish(MQTT_PATH, MQTT_MESSAGE)
time.sleep(1)


master.py:



import paho.mqtt.client as mqtt
import numpy as np
import json
import PIL

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

def on_connect(client, userdata, flags, rc):
print("connected with result code " + str(rc))
client.subscribe(MQTT_PATH)

def on_message(client, userdata, msg):
data = json.loads(msg.payload)
array = np.array(data)
img = PIL.Image.fromarray(array)
cv2.imshow('image', img)
cv2.waitKey()

client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect(MQTT_SERVER, 1883, 60)

client.loop_forever()









share|improve this question

























  • You need to explain what you have tried, just saying "I have performed debugging" doesn't help

    – hardillb
    Nov 19 '18 at 10:21











  • Also you are blocking in the on_message by calling cv2.waitKey() this means the whole subscriber will lock up while processing the first message until you press a key. You should not block messaging handling.

    – hardillb
    Nov 19 '18 at 10:25






  • 1





    Don't need to call mqttc.loop_start() in your client (or periodically call loop from within your for loop)?

    – larsks
    Nov 19 '18 at 12:40











  • @hardillb sorry i didnt specify the exact debugging techniques but i think it is redundant nonetheless because the servant script is working perfectly fine. But, to answer your question i did a few logging statements on the servant.py and the data is being processed properly and is jsonified. I also made a dummy numpy array and that actually went through and was published. But for some reason the moment i use opencv it stops working. Once again even with the opencv on the servant.py everything works fine, publishing is the problem.

    – Noor Sabbagh
    Nov 19 '18 at 13:05











  • @hardillb as for your suggestion I removed that line but there was still nothing showing up. Don't even think that is the problem, because i quickly debugged it using a print statement, first line in the on_message method, and the msg.payload's value is not printed. Which means that somewhere between the publish and the on_message something is going wrong.

    – Noor Sabbagh
    Nov 19 '18 at 13:07














0












0








0








I am currently implementing a MQTT protocol to be used between two raspberry pis. The first is a Pi 0 and will have a pi camera connected to it. It will be converting each captured frame to a numpy array and then publish it to the master Pi which will then convert the numpy array to an image using PIL. I am doing it this way since I want the main image processing operations to be performed on the master Pi.



My problem is that no messages are being received by the master Pi. I have preformed debugging and everything is working fine on the servant script. But for some reason nothing is received by the master Pi.



Here are both scripts:



servant.py:



import paho.mqtt.client as mqtt
import time
import cv2
import numpy
import json

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

mqttc = mqtt.Client()
mqttc.connect(MQTT_SERVER, 1883, 60)

cap = cv2.VideoCapture(0)

while True:
ret, frame = cap.read()
frame_list = frame.tolist()
MQTT_MESSAGE = json.dumps(frame_list)
mqttc.publish(MQTT_PATH, MQTT_MESSAGE)
time.sleep(1)


master.py:



import paho.mqtt.client as mqtt
import numpy as np
import json
import PIL

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

def on_connect(client, userdata, flags, rc):
print("connected with result code " + str(rc))
client.subscribe(MQTT_PATH)

def on_message(client, userdata, msg):
data = json.loads(msg.payload)
array = np.array(data)
img = PIL.Image.fromarray(array)
cv2.imshow('image', img)
cv2.waitKey()

client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect(MQTT_SERVER, 1883, 60)

client.loop_forever()









share|improve this question
















I am currently implementing a MQTT protocol to be used between two raspberry pis. The first is a Pi 0 and will have a pi camera connected to it. It will be converting each captured frame to a numpy array and then publish it to the master Pi which will then convert the numpy array to an image using PIL. I am doing it this way since I want the main image processing operations to be performed on the master Pi.



My problem is that no messages are being received by the master Pi. I have preformed debugging and everything is working fine on the servant script. But for some reason nothing is received by the master Pi.



Here are both scripts:



servant.py:



import paho.mqtt.client as mqtt
import time
import cv2
import numpy
import json

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

mqttc = mqtt.Client()
mqttc.connect(MQTT_SERVER, 1883, 60)

cap = cv2.VideoCapture(0)

while True:
ret, frame = cap.read()
frame_list = frame.tolist()
MQTT_MESSAGE = json.dumps(frame_list)
mqttc.publish(MQTT_PATH, MQTT_MESSAGE)
time.sleep(1)


master.py:



import paho.mqtt.client as mqtt
import numpy as np
import json
import PIL

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

def on_connect(client, userdata, flags, rc):
print("connected with result code " + str(rc))
client.subscribe(MQTT_PATH)

def on_message(client, userdata, msg):
data = json.loads(msg.payload)
array = np.array(data)
img = PIL.Image.fromarray(array)
cv2.imshow('image', img)
cv2.waitKey()

client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect(MQTT_SERVER, 1883, 60)

client.loop_forever()






python numpy raspberry-pi mqtt






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 '18 at 10:16







Noor Sabbagh

















asked Nov 19 '18 at 10:05









Noor SabbaghNoor Sabbagh

12




12













  • You need to explain what you have tried, just saying "I have performed debugging" doesn't help

    – hardillb
    Nov 19 '18 at 10:21











  • Also you are blocking in the on_message by calling cv2.waitKey() this means the whole subscriber will lock up while processing the first message until you press a key. You should not block messaging handling.

    – hardillb
    Nov 19 '18 at 10:25






  • 1





    Don't need to call mqttc.loop_start() in your client (or periodically call loop from within your for loop)?

    – larsks
    Nov 19 '18 at 12:40











  • @hardillb sorry i didnt specify the exact debugging techniques but i think it is redundant nonetheless because the servant script is working perfectly fine. But, to answer your question i did a few logging statements on the servant.py and the data is being processed properly and is jsonified. I also made a dummy numpy array and that actually went through and was published. But for some reason the moment i use opencv it stops working. Once again even with the opencv on the servant.py everything works fine, publishing is the problem.

    – Noor Sabbagh
    Nov 19 '18 at 13:05











  • @hardillb as for your suggestion I removed that line but there was still nothing showing up. Don't even think that is the problem, because i quickly debugged it using a print statement, first line in the on_message method, and the msg.payload's value is not printed. Which means that somewhere between the publish and the on_message something is going wrong.

    – Noor Sabbagh
    Nov 19 '18 at 13:07



















  • You need to explain what you have tried, just saying "I have performed debugging" doesn't help

    – hardillb
    Nov 19 '18 at 10:21











  • Also you are blocking in the on_message by calling cv2.waitKey() this means the whole subscriber will lock up while processing the first message until you press a key. You should not block messaging handling.

    – hardillb
    Nov 19 '18 at 10:25






  • 1





    Don't need to call mqttc.loop_start() in your client (or periodically call loop from within your for loop)?

    – larsks
    Nov 19 '18 at 12:40











  • @hardillb sorry i didnt specify the exact debugging techniques but i think it is redundant nonetheless because the servant script is working perfectly fine. But, to answer your question i did a few logging statements on the servant.py and the data is being processed properly and is jsonified. I also made a dummy numpy array and that actually went through and was published. But for some reason the moment i use opencv it stops working. Once again even with the opencv on the servant.py everything works fine, publishing is the problem.

    – Noor Sabbagh
    Nov 19 '18 at 13:05











  • @hardillb as for your suggestion I removed that line but there was still nothing showing up. Don't even think that is the problem, because i quickly debugged it using a print statement, first line in the on_message method, and the msg.payload's value is not printed. Which means that somewhere between the publish and the on_message something is going wrong.

    – Noor Sabbagh
    Nov 19 '18 at 13:07

















You need to explain what you have tried, just saying "I have performed debugging" doesn't help

– hardillb
Nov 19 '18 at 10:21





You need to explain what you have tried, just saying "I have performed debugging" doesn't help

– hardillb
Nov 19 '18 at 10:21













Also you are blocking in the on_message by calling cv2.waitKey() this means the whole subscriber will lock up while processing the first message until you press a key. You should not block messaging handling.

– hardillb
Nov 19 '18 at 10:25





Also you are blocking in the on_message by calling cv2.waitKey() this means the whole subscriber will lock up while processing the first message until you press a key. You should not block messaging handling.

– hardillb
Nov 19 '18 at 10:25




1




1





Don't need to call mqttc.loop_start() in your client (or periodically call loop from within your for loop)?

– larsks
Nov 19 '18 at 12:40





Don't need to call mqttc.loop_start() in your client (or periodically call loop from within your for loop)?

– larsks
Nov 19 '18 at 12:40













@hardillb sorry i didnt specify the exact debugging techniques but i think it is redundant nonetheless because the servant script is working perfectly fine. But, to answer your question i did a few logging statements on the servant.py and the data is being processed properly and is jsonified. I also made a dummy numpy array and that actually went through and was published. But for some reason the moment i use opencv it stops working. Once again even with the opencv on the servant.py everything works fine, publishing is the problem.

– Noor Sabbagh
Nov 19 '18 at 13:05





@hardillb sorry i didnt specify the exact debugging techniques but i think it is redundant nonetheless because the servant script is working perfectly fine. But, to answer your question i did a few logging statements on the servant.py and the data is being processed properly and is jsonified. I also made a dummy numpy array and that actually went through and was published. But for some reason the moment i use opencv it stops working. Once again even with the opencv on the servant.py everything works fine, publishing is the problem.

– Noor Sabbagh
Nov 19 '18 at 13:05













@hardillb as for your suggestion I removed that line but there was still nothing showing up. Don't even think that is the problem, because i quickly debugged it using a print statement, first line in the on_message method, and the msg.payload's value is not printed. Which means that somewhere between the publish and the on_message something is going wrong.

– Noor Sabbagh
Nov 19 '18 at 13:07





@hardillb as for your suggestion I removed that line but there was still nothing showing up. Don't even think that is the problem, because i quickly debugged it using a print statement, first line in the on_message method, and the msg.payload's value is not printed. Which means that somewhere between the publish and the on_message something is going wrong.

– Noor Sabbagh
Nov 19 '18 at 13:07












1 Answer
1






active

oldest

votes


















0














In your publishing code you are not actually giving the client any time to process the message it is trying to send. This is even more of a problem because the message is likely to be larger than a single network packet (being an image). To fix this you have to call the MQTT client loop function (or start the loop in the b



import paho.mqtt.client as mqtt
import time
import cv2
import numpy
import json

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

mqttc = mqtt.Client()
mqttc.connect(MQTT_SERVER, 1883, 60)

cap = cv2.VideoCapture(0)

while True:
ret, frame = cap.read()
frame_list = frame.tolist()
MQTT_MESSAGE = json.dumps(frame_list)
mqttc.publish(MQTT_PATH, MQTT_MESSAGE)
mqttc.loop()
time.sleep(1)


or like this:



import paho.mqtt.client as mqtt
import time
import cv2
import numpy
import json

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

mqttc = mqtt.Client()
mqttc.connect(MQTT_SERVER, 1883, 60)

cap = cv2.VideoCapture(0)

mqttc.start_loop()

while True:
ret, frame = cap.read()
frame_list = frame.tolist()
MQTT_MESSAGE = json.dumps(frame_list)
mqttc.publish(MQTT_PATH, MQTT_MESSAGE)
time.sleep(1)





share|improve this answer
























  • Thank you so much, one more question, do you think this is a good way of doing things or is there a more lightweight way of doing it? Actually in my real script im going to have the pi camera module on the servant.py instead of opencv. Is byte streaming the image to the master going to be more efficient and faster than my current way?

    – Noor Sabbagh
    Nov 19 '18 at 23:33











  • But the problem is still there. I removed the waitkey and added the loop for the client but the master is still not receiving anything.

    – Noor Sabbagh
    Nov 20 '18 at 0:14











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372285%2fpython-mqtt-publish-jsonified-numpy-array%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














In your publishing code you are not actually giving the client any time to process the message it is trying to send. This is even more of a problem because the message is likely to be larger than a single network packet (being an image). To fix this you have to call the MQTT client loop function (or start the loop in the b



import paho.mqtt.client as mqtt
import time
import cv2
import numpy
import json

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

mqttc = mqtt.Client()
mqttc.connect(MQTT_SERVER, 1883, 60)

cap = cv2.VideoCapture(0)

while True:
ret, frame = cap.read()
frame_list = frame.tolist()
MQTT_MESSAGE = json.dumps(frame_list)
mqttc.publish(MQTT_PATH, MQTT_MESSAGE)
mqttc.loop()
time.sleep(1)


or like this:



import paho.mqtt.client as mqtt
import time
import cv2
import numpy
import json

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

mqttc = mqtt.Client()
mqttc.connect(MQTT_SERVER, 1883, 60)

cap = cv2.VideoCapture(0)

mqttc.start_loop()

while True:
ret, frame = cap.read()
frame_list = frame.tolist()
MQTT_MESSAGE = json.dumps(frame_list)
mqttc.publish(MQTT_PATH, MQTT_MESSAGE)
time.sleep(1)





share|improve this answer
























  • Thank you so much, one more question, do you think this is a good way of doing things or is there a more lightweight way of doing it? Actually in my real script im going to have the pi camera module on the servant.py instead of opencv. Is byte streaming the image to the master going to be more efficient and faster than my current way?

    – Noor Sabbagh
    Nov 19 '18 at 23:33











  • But the problem is still there. I removed the waitkey and added the loop for the client but the master is still not receiving anything.

    – Noor Sabbagh
    Nov 20 '18 at 0:14
















0














In your publishing code you are not actually giving the client any time to process the message it is trying to send. This is even more of a problem because the message is likely to be larger than a single network packet (being an image). To fix this you have to call the MQTT client loop function (or start the loop in the b



import paho.mqtt.client as mqtt
import time
import cv2
import numpy
import json

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

mqttc = mqtt.Client()
mqttc.connect(MQTT_SERVER, 1883, 60)

cap = cv2.VideoCapture(0)

while True:
ret, frame = cap.read()
frame_list = frame.tolist()
MQTT_MESSAGE = json.dumps(frame_list)
mqttc.publish(MQTT_PATH, MQTT_MESSAGE)
mqttc.loop()
time.sleep(1)


or like this:



import paho.mqtt.client as mqtt
import time
import cv2
import numpy
import json

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

mqttc = mqtt.Client()
mqttc.connect(MQTT_SERVER, 1883, 60)

cap = cv2.VideoCapture(0)

mqttc.start_loop()

while True:
ret, frame = cap.read()
frame_list = frame.tolist()
MQTT_MESSAGE = json.dumps(frame_list)
mqttc.publish(MQTT_PATH, MQTT_MESSAGE)
time.sleep(1)





share|improve this answer
























  • Thank you so much, one more question, do you think this is a good way of doing things or is there a more lightweight way of doing it? Actually in my real script im going to have the pi camera module on the servant.py instead of opencv. Is byte streaming the image to the master going to be more efficient and faster than my current way?

    – Noor Sabbagh
    Nov 19 '18 at 23:33











  • But the problem is still there. I removed the waitkey and added the loop for the client but the master is still not receiving anything.

    – Noor Sabbagh
    Nov 20 '18 at 0:14














0












0








0







In your publishing code you are not actually giving the client any time to process the message it is trying to send. This is even more of a problem because the message is likely to be larger than a single network packet (being an image). To fix this you have to call the MQTT client loop function (or start the loop in the b



import paho.mqtt.client as mqtt
import time
import cv2
import numpy
import json

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

mqttc = mqtt.Client()
mqttc.connect(MQTT_SERVER, 1883, 60)

cap = cv2.VideoCapture(0)

while True:
ret, frame = cap.read()
frame_list = frame.tolist()
MQTT_MESSAGE = json.dumps(frame_list)
mqttc.publish(MQTT_PATH, MQTT_MESSAGE)
mqttc.loop()
time.sleep(1)


or like this:



import paho.mqtt.client as mqtt
import time
import cv2
import numpy
import json

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

mqttc = mqtt.Client()
mqttc.connect(MQTT_SERVER, 1883, 60)

cap = cv2.VideoCapture(0)

mqttc.start_loop()

while True:
ret, frame = cap.read()
frame_list = frame.tolist()
MQTT_MESSAGE = json.dumps(frame_list)
mqttc.publish(MQTT_PATH, MQTT_MESSAGE)
time.sleep(1)





share|improve this answer













In your publishing code you are not actually giving the client any time to process the message it is trying to send. This is even more of a problem because the message is likely to be larger than a single network packet (being an image). To fix this you have to call the MQTT client loop function (or start the loop in the b



import paho.mqtt.client as mqtt
import time
import cv2
import numpy
import json

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

mqttc = mqtt.Client()
mqttc.connect(MQTT_SERVER, 1883, 60)

cap = cv2.VideoCapture(0)

while True:
ret, frame = cap.read()
frame_list = frame.tolist()
MQTT_MESSAGE = json.dumps(frame_list)
mqttc.publish(MQTT_PATH, MQTT_MESSAGE)
mqttc.loop()
time.sleep(1)


or like this:



import paho.mqtt.client as mqtt
import time
import cv2
import numpy
import json

MQTT_SERVER = "iot.eclipse.org"
MQTT_PATH = "test_channel"

mqttc = mqtt.Client()
mqttc.connect(MQTT_SERVER, 1883, 60)

cap = cv2.VideoCapture(0)

mqttc.start_loop()

while True:
ret, frame = cap.read()
frame_list = frame.tolist()
MQTT_MESSAGE = json.dumps(frame_list)
mqttc.publish(MQTT_PATH, MQTT_MESSAGE)
time.sleep(1)






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 19 '18 at 14:01









hardillbhardillb

24.5k73160




24.5k73160













  • Thank you so much, one more question, do you think this is a good way of doing things or is there a more lightweight way of doing it? Actually in my real script im going to have the pi camera module on the servant.py instead of opencv. Is byte streaming the image to the master going to be more efficient and faster than my current way?

    – Noor Sabbagh
    Nov 19 '18 at 23:33











  • But the problem is still there. I removed the waitkey and added the loop for the client but the master is still not receiving anything.

    – Noor Sabbagh
    Nov 20 '18 at 0:14



















  • Thank you so much, one more question, do you think this is a good way of doing things or is there a more lightweight way of doing it? Actually in my real script im going to have the pi camera module on the servant.py instead of opencv. Is byte streaming the image to the master going to be more efficient and faster than my current way?

    – Noor Sabbagh
    Nov 19 '18 at 23:33











  • But the problem is still there. I removed the waitkey and added the loop for the client but the master is still not receiving anything.

    – Noor Sabbagh
    Nov 20 '18 at 0:14

















Thank you so much, one more question, do you think this is a good way of doing things or is there a more lightweight way of doing it? Actually in my real script im going to have the pi camera module on the servant.py instead of opencv. Is byte streaming the image to the master going to be more efficient and faster than my current way?

– Noor Sabbagh
Nov 19 '18 at 23:33





Thank you so much, one more question, do you think this is a good way of doing things or is there a more lightweight way of doing it? Actually in my real script im going to have the pi camera module on the servant.py instead of opencv. Is byte streaming the image to the master going to be more efficient and faster than my current way?

– Noor Sabbagh
Nov 19 '18 at 23:33













But the problem is still there. I removed the waitkey and added the loop for the client but the master is still not receiving anything.

– Noor Sabbagh
Nov 20 '18 at 0:14





But the problem is still there. I removed the waitkey and added the loop for the client but the master is still not receiving anything.

– Noor Sabbagh
Nov 20 '18 at 0:14




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372285%2fpython-mqtt-publish-jsonified-numpy-array%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini