0
$\begingroup$

I made a simple blender model to output the RGB, Depth and Mask picture respectively.

As shown in the image below, there are many cars of the same type on the ground in both RGB image and depth image, however the Mask image only shows one car. Note that the car is in the same type, if I used n different types of cars, the mask picture will show only n different cars.

enter image description here

This is my node

enter image description here

Any ideas ?


I know what goes wrong here, it is nothing about the model but because of the object index.

In my model, i have only one object, then I used the code to duplicate to many more, therefore probably the new generated object has not the same object index as the original one.

Here is my code for creating a new object.

  def createCarWithName(self,name):
      obj = bpy.data.objects[name]
      mesh = obj.data
      new_obj = bpy.data.objects.new(name, mesh)
      bpy.context.scene.objects.link(new_obj)
      new_obj.rotation_mode = 'XYZ'# Force the right rotation mode
      new_obj.pass_index = 4

Though you have shown me the way to give the objects the same object index manually, I tried to give the object the pass_index, and it worked.

$\endgroup$

1 Answer 1

2
$\begingroup$

The object index is a property that is unique to each object, you need to have every object set to the same index if you want them to show up in the same mask.

You can do this easily by selecting all of the cars, then right clicking on the object index and choosing Copy To Selected.

Copy value to selected

Another way is to use the same material on each car and use the material index instead of object index.

As you are duplicating the cars using python, you can set the pass_index as you create each car.

def createCarWithName(self,name):
    obj = bpy.data.objects[name]
    mesh = obj.data
    new_obj = bpy.data.objects.new(name, mesh)
    bpy.context.scene.objects.link(new_obj)
    new_obj.rotation_mode = 'XYZ'# Force the right rotation mode
    new_obj.pass_index = 1
$\endgroup$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .