Python MQTT Publish JSONified Numpy Array
up vote
0
down vote
favorite
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
|
show 2 more comments
up vote
0
down vote
favorite
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
You need to explain what you have tried, just saying "I have performed debugging" doesn't help
– hardillb
Nov 19 at 10:21
Also you are blocking in theon_message
by callingcv2.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 at 10:25
1
Don't need to callmqttc.loop_start()
in your client (or periodically callloop
from within your for loop)?
– larsks
Nov 19 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 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 theon_message
method, and themsg.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 at 13:07
|
show 2 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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
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
python numpy raspberry-pi mqtt
edited Nov 19 at 10:16
asked Nov 19 at 10:05
Noor Sabbagh
12
12
You need to explain what you have tried, just saying "I have performed debugging" doesn't help
– hardillb
Nov 19 at 10:21
Also you are blocking in theon_message
by callingcv2.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 at 10:25
1
Don't need to callmqttc.loop_start()
in your client (or periodically callloop
from within your for loop)?
– larsks
Nov 19 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 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 theon_message
method, and themsg.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 at 13:07
|
show 2 more comments
You need to explain what you have tried, just saying "I have performed debugging" doesn't help
– hardillb
Nov 19 at 10:21
Also you are blocking in theon_message
by callingcv2.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 at 10:25
1
Don't need to callmqttc.loop_start()
in your client (or periodically callloop
from within your for loop)?
– larsks
Nov 19 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 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 theon_message
method, and themsg.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 at 13:07
You need to explain what you have tried, just saying "I have performed debugging" doesn't help
– hardillb
Nov 19 at 10:21
You need to explain what you have tried, just saying "I have performed debugging" doesn't help
– hardillb
Nov 19 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 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 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 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 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 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 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 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 at 13:07
|
show 2 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
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)
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 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 at 0:14
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
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)
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 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 at 0:14
add a comment |
up vote
0
down vote
accepted
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)
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 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 at 0:14
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
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)
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)
answered Nov 19 at 14:01
hardillb
23.4k63059
23.4k63059
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 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 at 0:14
add a comment |
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 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 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 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 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 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 at 0:14
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
You need to explain what you have tried, just saying "I have performed debugging" doesn't help
– hardillb
Nov 19 at 10:21
Also you are blocking in the
on_message
by callingcv2.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 at 10:25
1
Don't need to call
mqttc.loop_start()
in your client (or periodically callloop
from within your for loop)?– larsks
Nov 19 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 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 themsg.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 at 13:07