Unity-ZeroMQ-Example icon indicating copy to clipboard operation
Unity-ZeroMQ-Example copied to clipboard

Example for sending images from Unity to Python

Open Guidosalimbeni opened this issue 6 years ago • 7 comments

I wonder if you could provide also an example of how to send an image from Unity to python (for example a render from the camera view in unity to python). That would be great thanks

Guidosalimbeni avatar Aug 04 '18 11:08 Guidosalimbeni

did you ever figure it out @Guidosalimbeni ?

bc avatar May 17 '19 20:05 bc

Need the solution as well. Have you ever figured it out? @bc @Guidosalimbeni

Terminou avatar Jun 07 '20 20:06 Terminou

Didn’t end up needing it. You just have to serialize the file as a string (like base64), send it as a normal message, and then in python decode the string back. zmq just uses strings to send messages (or bytes), so if you can turn whatever you want it to a string, you can send it

bc avatar Jun 07 '20 21:06 bc

@bc Do you have an example code? I could not figure out though I've tried everything :)

Terminou avatar Jun 09 '20 19:06 Terminou

Here are the pieces:

  1. C# save a picture from the device camera
  2. C# load that file as a base64 string
  3. C#: send that string to your ZMQ python endpoint (using same approach as in this example repo)
  4. Python: receive that string, and pass it to base64.b64decode(message_string)

bc avatar Jun 10 '20 02:06 bc

Here are the pieces:

  1. C# save a picture from the device camera
  2. C# load that file as a base64 string
  3. C#: send that string to your ZMQ python endpoint (using same approach as in this example repo)
  4. Python: receive that string, and pass it to base64.b64decode(message_string)

Done! Thank you for taking the time to answer my question. It was really helpful. I appreciate it.

Terminou avatar Jun 10 '20 05:06 Terminou

can we send pictures from python to unity ? how ?

AliAnisNOURA avatar Oct 30 '21 17:10 AliAnisNOURA