DIYer22 / bpycv

Computer vision utils for Blender (generate instance annoatation, depth and 6D pose by one line code)
MIT License
464 stars 58 forks source link

color_depth left changed by bpycv.render_data #5

Closed alekseynp closed 3 years ago

alekseynp commented 4 years ago

Easy enough to workaround by manually fixing after the call, but I can see you go to some advanced effort in the code to change and then reset parameters like this.

Blender 2.80

To reproduce, from Blender launch:

In the Scripting Console:

>>> import bpycv
/opt/blender/blender-2.80/2.80/python/lib/python3.7/site-packages/bs4/element.py:16: UserWarning: The soupsieve package is not installed. CSS selectors cannot be used.
  'The soupsieve package is not installed. CSS selectors cannot be used.'
>>> bpy.context.scene.render.image_settings.color_depth
'8'
>>> bpycv.render_data(render_image=False)
# results...
>>> bpy.context.scene.render.image_settings.color_depth
'16'
>>> bpycv.__version__
'0.2.9'
DIYer22 commented 4 years ago

Thank you for report the issue.

It look like blender itself make this unexpected color_depth modify.

When change output file_format to 'OPEN_EXR' then change back to 'PNG', the bug happend.

Here is python example to reproduce this bug:

>>> bpy.context.scene.render.image_settings.file_format
'PNG'
>>> bpy.context.scene.render.image_settings.color_depth
'8'
>>> bpy.context.scene.render.image_settings.file_format = 'OPEN_EXR'
>>> bpy.context.scene.render.image_settings.file_format = 'PNG'
>>> bpy.context.scene.render.image_settings.color_depth
'16'

Using GUI do those steps could reproduce bug too.

alekseynp commented 4 years ago

Does that mean this line is being ignored? https://github.com/DIYer22/bpycv/blob/6268b58812d15b9a8464939f19527b4ab41c9be2/bpycv/render_utils.py#L50

DIYer22 commented 4 years ago

no

...
        attrs = dict(
            file_format="OPEN_EXR",
            color_mode="RGBA",
            color_depth="32",
            use_zbuffer=True,
        )
        self.set_attrs(render.image_settings, attrs)

when set file_format="OPEN_EXR", Blender modify color_depth to "16" automaticly.

So, color_depth's value is "16", befor the line color_depth="32"