Hi
I am sending a Numpy int array over RabbitMQ and it seem to be receiving correctly.
This is the output RabbitMQ's publish that is sent:
>py msg_send_test.py
>py msg_receive_test.py
Any suggestions would be appreciated.
Thanks...
When I try using Numpy's fromstring method:
I am sending a Numpy int array over RabbitMQ and it seem to be receiving correctly.
This is the output RabbitMQ's publish that is sent:
>py msg_send_test.py
Output: [x] Sent '0,1617731222,1617731222810382600,4,[ 48 251 9 205]'
This is the output on the receiving end from RabbitMQ's consumer:>py msg_receive_test.py
Output: [*] Waiting for messages. To exit press CTRL+C
[x] message '0,1617732445,1617732445003573700,4,[209 227 205 72]'
[x] message type <class 'str'>
[x] parts ['0', '1617732445', '1617732445003573700', '4', '[209 227 205 72]']
[x] parts len 5
[x] imageStr [209 227 205 72]
[x] imageStr type <class 'str'>
This is the section of code to produce the output from the RabbitMQ consumer:message = body.decode() parts = message.split(',') print("[x] message %r" % message) print("[x] message type %s" % type(message)) print("[x] parts %s" % parts) print("[x] parts len %s" % len(parts)) imageStr = str(parts[4]) print("[x] imageStr %s" % imageStr) print("[x] imageStr type %s" % type(imageStr))What I would like to do is convert the imageStr into a Numpy array of ints. The whole array is a string, not an array of individual strings.
Any suggestions would be appreciated.
Thanks...
When I try using Numpy's fromstring method:
imageArr = np.fromstring(imageStr, dtype=float, sep=' ') print("[x] imageArr type %s" % type(imageArr)) print("[x] ", imageArr)it gives the following output:
Output:[x] imageStr type <class 'str'>
[x] imageArr type <class 'numpy.ndarray'>
[x] []