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 Package, Segmenting Specific Surfaces

Discussion in 'Computer Vision' started by d_pepley, May 24, 2021.

  1. d_pepley

    d_pepley

    Joined:
    Oct 2, 2020
    Posts:
    18
    Using the perception package I understand how to do basic object segmentation, but I was interested in automating more advanced forms types of annotation such as specifically segmenting out the top surface of boxes. For example, imagine a pile of boxes with a camera looking down on them. For this, I specifically want to segment out just the top surfaces of the boxes, not the sides. Would it be possible to create a new segmentation type for this?

    Another option for achieving this that I have thought about is creating a box made of 6 objects, so that each side is labeled separately. However, for this to work, I would need to be able to turn off the sides that aren't facing upward. I haven't found a way to turn labels on and off while the sim is running. Is this possible?

    Thanks!
     
  2. Steven-CV

    Steven-CV

    Unity Technologies

    Joined:
    Jul 25, 2019
    Posts:
    5
    Instead of creating a new custom Labeler, I think you're right on target with your second idea. Turning off the labels on the non-top sides is possible by disabling their respective labeling components. To disable a Labeling component on a particular GameObject, you would use:
    Code (CSharp):
    1. obj.GetComponent<Labeling>().enabled = false;
    The only tricky bit left would be to determine which side of the box is currently facing up in a given frame to decide which sides should be enabled/disabled. One way to do this would be to take the normal vector of each of the 6 box faces and then calculate the angle of each face normal with respect to the up vector in world space. Whichever face's normal vector has the smallest angle relative to the up vector is the side facing up.
     
  3. StevenBorkman

    StevenBorkman

    Joined:
    Jun 17, 2020
    Posts:
    16
    Are the boxes dynamic in the scene, as in, are they going to be able to rotate? Because if not, if you know that one side of the box is always facing up, you can create a box that is made of a couple of meshes and only label the top mesh. In this example below, which is very trivial and I wouldn't recommend doing it like this because of z-fighting issues with the top plane and the cube, I have only labeled the 'Top' plane game object with a "BoxTop" label. The final screen shot shows the results of the semantic segmentation labeler. Like (the other) Steven said previously, if you have a dynamic scene then I think you will have to turn on and off the labels on the sides based on the dot product between their surface normal and the Vector3.up normal.

    upload_2021-5-25_10-42-43.png upload_2021-5-25_10-43-8.png upload_2021-5-25_10-43-43.png
     
  4. d_pepley

    d_pepley

    Joined:
    Oct 2, 2020
    Posts:
    18
    Yes, the boxes will have a random orientation. I tried out Steven's method of turning the labels off and on using getComponent and it works great! Thanks!
     
    Steven-CV and StevenBorkman like this.