Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Perception SDK: Ways to Store Prefab info in Scenario config

Discussion in 'Computer Vision' started by VivekSagar, Oct 11, 2021.

  1. VivekSagar

    VivekSagar

    Joined:
    Nov 9, 2016
    Posts:
    8
    We have multiple simulation environments that different people are working on in the same project. We'd like to keep the same Unity Project and just switch out the Scenario based on what is required to be simulated. Scenarios currently provide a way to save the config into a JSON but this only saves the numerical values, no information about which prefabs are in the scenario. Is there a way to save this info as well? We previously did this by just saving out a Scriptable Object instead of a JSON, but it seems like adding a Scriptable Object Config on top of the Simulation config will complicate things. Would be ideal to have just one file with all the config information.
     
  2. RuiyuZhang_Unity

    RuiyuZhang_Unity

    Unity Technologies

    Joined:
    Mar 17, 2021
    Posts:
    11
    Hi Vivek,

    Have you tried the RenderedObjectInfoLabeler provided by the perception camera? It gives label id, instance id, and visible pixel count in a single metric each frame for each object in the camera's frame.

    I hope this helps, let me know if you have any further questions!

    Best,
    Ruiyu Zhang
     
  3. VivekSagar

    VivekSagar

    Joined:
    Nov 9, 2016
    Posts:
    8
    As I understand it, RenderedObjectInfoLabeler provides metrics for the objects that have been instantiated in the scene already.
    What I'm looking for is a way to save the list of all the objects that are allowed to be instantiated in the current scenario.
    As an example, in the Perception Tutorial , I'd like to save out the state of BackgroundObjectPlacementRandomizer so that if someone else comes in and changes the prefabs inside, I can later reload my old state and continue work.
     
  4. Steven-CV

    Steven-CV

    Unity Technologies

    Joined:
    Jul 25, 2019
    Posts:
    5
    Hi Vivek!

    Unfortunately the Perception package's scenario configuration serialization functionality is rather limited at the moment. The tooling does not currently support serializing UnityEngine.Object derived data (Monobehaviours and ScriptableObjects) or arrays (string arrays, float arrays, etc.) into the scenario configuration. If I recall correctly, outside of Perception supported randomization parameters and samplers, only integer, float, and string fields on Randomizers can be serialized.
     
    RuiyuZhang_Unity likes this.
  5. Steven-CV

    Steven-CV

    Unity Technologies

    Joined:
    Jul 25, 2019
    Posts:
    5
    I may have a suggestion though. Feel free to correct me if I'm misunderstanding you use case.

    If the goal is to load different scene environments by changing JSON scenario configurations, you can:
    1. Create a ScriptableObject that contains all the information needed to recreate a particular environment
    2. Author a Randomizer that chooses from an array/dictionary of these environment ScriptableObjects at the start of the scenario
    3. Add an integer/string field to this EnvironmentRandomizer that loads the environment or prefabs described by the environment ScriptableObject located at that particular integer-index/string-key in the array

    By this step, you should be able to modify one integer/string field in the JSON scenario configuration serialized from this scenario to load different environments into your scene.

    Unfortunately, this solution is also limited in that you won't be able to see a complete list of environment options serialized into the JSON configuration if that is the priority.
     
    Last edited: Oct 14, 2021
    RuiyuZhang_Unity likes this.
  6. VivekSagar

    VivekSagar

    Joined:
    Nov 9, 2016
    Posts:
    8
    Got it. Thanks for the info! Using a separate ScriptableObject was the direction I was planning to go, but wanted to check if there was anything built in for this.