thodan / bop_toolkit

A Python toolkit of the BOP benchmark for 6D object pose estimation.
http://bop.felk.cvut.cz
MIT License
376 stars 135 forks source link

fix(#74): change renderer singleton to depend on initial arguments #82

Closed Sebastian-Jung closed 1 year ago

Sebastian-Jung commented 1 year ago

As mentioned in #74, creating vispsy renderer with different properties was not possible since a singleton was used. We keep the singleton behavior since it's not clear if not using it might brake something (@wangg12 you might know a bit more about this) , but the singleton now depends on the arguments passed to it.

Examples:

# Previously (bug)
depth_ren = renderer_vispy.RendererVispy(width, height, mode='depth')
rgb_ren = renderer_vispy.RendererVispy(width, height, mode='rgb')

assert id(depth_ren) != id(rgb_ren)
# > Throws error

# After the fix
depth_ren = renderer_vispy.RendererVispy(width, height, mode='depth')
rgb_ren = renderer_vispy.RendererVispy(width, height, mode='rgb')

assert id(depth_ren) != id(rgb_ren)
# > Doesn't throw an error

Note that the class provided here is based on https://gist.github.com/wowkin2/3af15bfbf197a14a2b0b2488a1e8c787

This also fixes a bug in the generation script render_train_imgs.py where two renderer were created but both created rgb images.

MartinSmeyer commented 1 year ago

looks good!