jeffbass / imagezmq

A set of Python classes that transport OpenCV images from one computer to another using PyZMQ messaging.
MIT License
1.02k stars 161 forks source link

Unable to send Reply back to Rpi from Host #33

Closed vasu15 closed 4 years ago

vasu15 commented 4 years ago

Hi, I was unable to send a response back to Rpi using ImageHub send_reply.

jeffbass commented 4 years ago

The Mac (image receiving computer) always sends a response. My test programs don't show how to capture the Mac's response in the RPi sending program. To capture the response, you add a variable to receive the return value of the "sender.send_image()" function:

rpi_name = socket.gethostname()  # send RPi hostname with each image
picam = VideoStream(usePiCamera=True).start()
time.sleep(2.0)  # allow camera sensor to warm up
while True:  # send images as stream until Ctrl-C
    image = picam.read()
    reply_from_mac = sender.send_image(rpi_name, image)   # captures the reply
    do_something_with_reply(reply_from_mac)

Above code snippet is from "test2_rpi_send_images.py" in the tests folder. Adding reply capture to the other test programs would be similar. I think your question is a good one. I will add something to the documentation to discuss this. Please let me know if above answers your question so I can close the issue. Thanks! Jeff

vasu15 commented 4 years ago

Thank You

On Tue, 25 Feb 2020 at 23:38, Jeff Bass notifications@github.com wrote:

The Mac (image receiving computer) always sends a response. My test programs don't show how to capture the Mac's response in the RPi sending program. To capture the response, you add a variable to receive the return value of the "sender.send_image()" function:

rpi_name = socket.gethostname() # send RPi hostname with each image picam = VideoStream(usePiCamera=True).start() time.sleep(2.0) # allow camera sensor to warm upwhile True: # send images as stream until Ctrl-C image = picam.read() reply_from_mac = sender.send_image(rpi_name, image) # captures the reply do_something_with_reply(reply_from_mac)

Above code snippet is from "test2_rpi_send_images.py" in the tests folder. Adding reply capture to the other test programs would be similar. I think your question is a good one. I will add something to the documentation to discuss this. Please let me know if above answers your question so I can close the issue. Thanks! Jeff

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jeffbass/imagezmq/issues/33?email_source=notifications&email_token=AE4REAIFS5XKGJTNBLJPYZTREVNB3A5CNFSM4K3JQYQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEM44W2Y#issuecomment-590990187, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE4REAPDTSXLQOZY2HAWB5DREVNB3ANCNFSM4K3JQYQQ .

jeffbass commented 4 years ago

I have updated the 2 programs timing_send_images.py and timing_send_jpg_buf.py to provide another example of how this is done. Let me know if you have any other questions.