I have a camera and a pile of up to 10 cubes. I know the position and orientation of the cubes and the camera. Now I would like to figure out what pixel belongs to what cube and create a labeled image where every pixel belongs to either a cube or nothing. Now I saw this question and the last answer gives a nice list of options. Now the thing is this is just a means to generate a dataset to train a model. The only way I know how I could do that would be to insert the coordinates of my cubes into some game/modeling engine like unity/blender and use existing functions, but this would only be by hand.
What I'm looking for is a small and simple library(c++/python) that let's me insert a few cubes and let's me determine the visibility of the pixels programmatically. Right now the only thing I can think of is writing my own ray casting plus polygonisation algorithm, which can't be the right approach.