Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Recommended image transport method (performance)

Discussion in 'Robotics' started by edvart-ros, Feb 12, 2024.

  1. edvart-ros

    edvart-ros

    Joined:
    Aug 15, 2023
    Posts:
    26
    What's the recommended way to transport images from Unity to ROS? Currently I'm getting significant performance hits when doing the publishing the straight-forward way. I read some threads on the github where someone recommended just *not* streaming images from Unity to ROS directly, someone mentioned using an http protocol instead. Is there any general advice on this? Real-time video feedback is pretty crucial for a lot of ROS/robotics systems. Here's essentially what I'm doing now, btw:

    Code (CSharp):
    1.     void SendImageCompressed()
    2.     {
    3.         var oldRT = RenderTexture.active;
    4.         RenderTexture.active = sensorCamera.targetTexture;
    5.         sensorCamera.Render();
    6.  
    7.         camText.ReadPixels(rectangle, 0, 0);
    8.         camText.Apply();
    9.         RenderTexture.active = oldRT;
    10.  
    11.         msg = camText.ToCompressedImageMsg_JPG(headerMsg);
    12.         ros.Publish(topicName, msg);
    13.     }
    14. }