DIYer22 / bpycv

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

occurred an error on demo #9

Closed iamrosemble closed 4 years ago

iamrosemble commented 4 years ago

I've tried to run your demo in the main page but it failed to finish. I just installed your library and boxx, opencv-python, bs4(I'm not sure why bs4 is needed for this), OpenEXR , simply copied your demo src in text editor and ran the script.

Error message is below: /home/noname/blender-2.90.0-linux64/2.90/python/lib/python3.7/site-packages/bpycv/utils.py:58: RuntimeWarning: divide by zero encountered in floor_divide numerator_odd = numerator // low_bit /home/noname/blender-2.90.0-linux64/2.90/python/lib/python3.7/site-packages/bpycv/utils.py:60: RuntimeWarning: divide by zero encountered in log2 up = np.int32(np.log2(low_bit, dtype=np.float32)) Traceback (most recent call last): File "/Text", line 22, in File "/home/noname/blender-2.90.0-linux64/2.90/python/lib/python3.7/site-packages/bpycv/render_utils.py", line 96, in render_data result = ImageWithAnnotation(render_result) File "/home/noname/blender-2.90.0-linux64/2.90/python/lib/python3.7/site-packages/bpycv/exr_image_parser.py", line 66, in init self["inst"] = exr.get_inst() File "/home/noname/blender-2.90.0-linux64/2.90/python/lib/python3.7/site-packages/bpycv/exr_image_parser.py", line 55, in get_inst inst = encode_inst_id.rgb_to_id(rgb) File "/home/noname/blender-2.90.0-linux64/2.90/python/lib/python3.7/site-packages/bpycv/utils.py", line 62, in rgb_to_id int_part = 2 (depth - 1) - 1 + idx_in_level ValueError: Integers to negative integer powers are not allowed. Error: Python script failed, check the message in the system console

I tried this in blender 2.82 also but no luck as same. Any suggestions will be helpful. Thanks.

DIYer22 commented 4 years ago

Thank you for report this BUG, I have fix it by this commit . You can upgrade bpycv to version 0.2.17 and try again.

DIYer22 commented 4 years ago

bs4(I'm not sure why bs4 is needed for this)

bs4 is used to download .hdri file from hdrihaven for "Pre-define domain randomization: enviroment"

iamrosemble commented 4 years ago

Thank you for a quick response. I ran the demo script and it worked with no error. But I think it is slightly different from what I expected. (See below) depth image has no volumetric data(just B&W binary color) and inst image is too dark. Did I do something wrong or just another glitch?

Anyway, I'm also making my own instance annotation script. This gave me a big inspiration. Perhaps it'll be great to have a method to generate a pixel position data of each instance. (I usually used findcontour in opencv) Thank you for your work.

demo-depth demo-inst demo-rgb demo-vis(inst|rgb|depth)

DIYer22 commented 4 years ago

depth image has no volumetric data

This only happen in Blender 2.90, because Blender change infinity depth from 1e9 to 6e4. I have fix it by this commit . You can upgrade bpycv to version 0.2.20 and try again.

DIYer22 commented 4 years ago

inst image is too dark

inst image is used for python code, not for human to see or understanding. The value of each pixel represents the inst_id of the object to which the pixel belongs. So, it's normal that look like too dark for human.

This code could visualization inst image by skimage.exposure.equalize_hist.

from boxx import show, imread
from skimage.exposure import equalize_hist
inst = imread('demo-inst.png')
show(equalize_hist(inst))